fix: make Application listen promise resolve after aborted #685
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Oak community / cc @kitsonk,
Edited on 12th Dec 24: should close #686 and close #687
I'm using Oak heavily at work (kudos to all for the cool library of course 😀).
I notice (at current version
v17.1.3
) the server listen promise doesn't resolve itself even after alreadyabort
ed.Naive reproduction attempt:
If we do it like the above, then we never see the last line logged out in the console. This suggests the
await p
expression never resolves (forever staying atpending
state).I was a bit curious how it behaves differently from the doc, so I dug a bit & it resulted in this PR.
I leave the PR asdraft
so we can discuss more where needed.update 6th Dec: I mark the PR as ready for visibility - always happy to consider alternatives or feedback :)
Side note:
During the process, I also noticed a related unit test was disabled. I think it was disabled due to another (slightly related) reason: the server needs a bit of time to initialize itself, so if we call
abort()
right afterlisten()
(as done in the originally disabled test), then the signal is alreadyabort
ed by the time the server initializes, and so we "miss" the chance to properly abort it.To this end, I also re-enabled that test, plus I added another test so we cover both scenarios. The PR content explains better than my words here tho 😀
Thank you everyone for your insights / reviews / discussions / objections etc. 🙌 !