-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mqtt5 client event handler bindings leave open handles keeping node process running #600
Comments
Yes, we've implemented it properly with initialize(), stop(), close() and even with the disconnect packet for stop(). Everything that was async was awaited properly. The reproduction provided is a distilled version to provide the least amount of code. |
Calling close makes the client eligible for garbage collection. The bindings are destroyed as part of garbage collection, but we cannot force node to garbage collect anything. |
I've tried to force node to garbage collect with |
The only way I've found to "reliably" trigger actual GC is to apply memory pressure (large local allocations) while invoking the gc (which might not actually be necessary). |
Still thinking about this. There may be something we can do but I'll need to convince others that the investigation time is worthwhile. If we get something working, it may also be applicable to the longstanding #291 |
Thanks for the quick responses. We've managed to workaround this issue by using MQTT.js. If this is ever investigated further, that might make a good reference for comparison. We can close this issue if desired or leave it open as a record of the issue. |
Describe the bug
The AWS MQTT5 client leaves open handles on its event handlers that are instantiated within the constructor. These open handles prevent NodeJS process from closing properly.
I was able to create a simple script that replicates the issue. It shows the same open handles that I've found when using
why-is-node-running
with our test framework.The open handles are are from the AWS MQTT5 Client event handler bindings shown by
why-is-node-running
:If you have any idea of how to resolve/avoid this issue, please let me know.
Regression Issue
Expected Behavior
I expect the AWS MQTT5 client event handlers to be cleaned up successfully allowing the NodeJS process to close successfully.
Current Behavior
The AWS MQTT5 client leave open handles for the event handlers which prevents NodeJS process from closing and causing it to hang.
Reproduction Steps
Here is a simple package file and NodeJS script file to replicate the issue, my coworker was able to get the same console output with these. However, you'll need your own AWS IoT endpoint, private key pem file and client certificate file.
package.json
test.js script
And just run
npm install
andnode ./test.js
.Possible Solution
No response
Additional Information/Context
No response
aws-crt-nodejs version used
1.21.8
nodejs version used
20.18.1
Operating System and version
Ubuntu 22.04.5 LTS
The text was updated successfully, but these errors were encountered: