Created
June 19, 2025 21:29
-
-
Save termi/c5dfc799ff565e95349a35db9fccc747 to your computer and use it in GitHub Desktop.
MRE for "Aborting `signal` of server.lister method before actual listeting begin put a `listen` promise into a floating state"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add into test/server.test.js | |
await t.test('listen should not start server if already aborted 2', async (t) => { | |
t.plan(2) | |
const controller = new AbortController() | |
controller.abort(new Error('aborting before actual start')) | |
const fastify = Fastify() | |
try { | |
// promise returning by fastify.listen is in "floating" state | |
await fastify.listen({ port: 1234, signal: controller.signal }) | |
// unreachable code | |
} catch (e) { | |
// unreachable code | |
t.assert.strictEqual(e.message, 'aborting before actual start') | |
} | |
// unreachable code | |
t.assert.strictEqual(fastify.server.listening, false) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment