Open karimfromjordan opened 3 weeks ago
Latest commit: 716e2fd3b6af4317bd03e1ad4186fcec4b260cb6
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
This is a small improvement and the missing piece to the recent graceful shutdown feature. After the server has closed gracefully Node will emit the
exit
event. As others have pointed out however if you have something running in the background the app will continue to run andexit
will never be emitted. Theexit
event isn't ideal anyway because it will close your app as soon as possible so we can't do any custom async cleanup work in aprocess.on('exit', () => { ... })
handler. That means callingprocess.exit()
to manually emit theexit
event isn't an option. It defeats the point of a graceful shutdown. This PR emits a custom event instead that users ofadapter-node
can listen to and use to perform any kind of cleanup work right after the HTTP server has closed.We briefly discussed the option of exporting a function to register a hook instead but with the way adapters work this doesn't seem to be possible today.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.Edits