-
Notifications
You must be signed in to change notification settings - Fork 32
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
Stop
does not properly wait for the server to close
#5
Comments
Thank you |
🎉 This issue has been resolved in version 2.0.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Hey @gajus, thanks for taking a look at this. If you don't mind a suggestion, I'd create a new promise that resolves when your server is closed (or fails to close I guess) rather than calling |
This behaviour is by design. The idea is that Lightship registers all the I have added a warning about the active event loop preventing the program to gracefully exit and changed the exit code to 1. Does this seem reasonable solution? If not, please advise how would you handle it, since the requirement is to terminate the program within a given time limit. |
🎉 This issue has been resolved in version 2.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Ah, yea, that makes a lot of sense. I was thinking about this incorrectly. I think the warning is a nice touch though since that might help people find dangling resources that they missed cleaning up. In that case, my only remaining suggestion would be to use |
Cannot really do that. Suppose that user does this. const connection = [..];
registerShutdownHandler(async () => {
await connection.query([..]);
});
registerShutdownHandler(async () => {
await connection.end();
}); Using |
Sure, but do you feel that it's correct for users to depend on the ordering of shutdown handlers in your lib? It feels more correct for them to have done something like: registerShutdownHandler(async () => {
try {
await connection.query([..]);
} finally {
await connection.end();
}
}); rather than depending on implementation details of this lib to determine whether or not the resource is still available |
Fair point. I will come back to this in a bit. Don't want to rush the change. Will check how comparable libraries implement shutdown handler execution. |
This wouldn't be safe though: registerShutdownHandler(async () => {
try {
await connection.query([..]);
} finally {
await connection.end();
}
});
registerShutdownHandler(async () => {
try {
await connection.query([..]);
} finally {
await connection.end();
}
}); |
Just do: registerShutdownHandler(async () => {
await Promise.all([
userCollectionOfShutdownHandlers,
]);
}); if you need parallelism. |
Thanks for providing this lib, I was about to write something like this when I saw you mention this in the k8s slack channel :)
Was looking through the code and noticed that the
stop
method does not properly wait for the server to close since no callback is provided. Since the method was markedasync
, it seems like you had intended for it to wait.lightship/src/factories/createLightship.js
Line 133 in c453672
The text was updated successfully, but these errors were encountered: