-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #48717 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
- Loading branch information
1 parent
17f6b8c
commit 0e9138d
Showing
3 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as common from '../common/index.mjs'; | ||
import assert from 'node:assert'; | ||
import net from 'node:net'; | ||
import { describe, it } from 'node:test'; | ||
|
||
describe('net.Server[Symbol.asyncDispose]()', () => { | ||
it('should close the server', async () => { | ||
const server = net.createServer(); | ||
const timeoutRef = setTimeout(common.mustNotCall(), 2 ** 31 - 1); | ||
|
||
server.listen(0, common.mustCall(async () => { | ||
await server[Symbol.asyncDispose]().then(common.mustCall()); | ||
assert.strictEqual(server.address(), null); | ||
clearTimeout(timeoutRef); | ||
})); | ||
|
||
server.on('close', common.mustCall()); | ||
}); | ||
|
||
it('should resolve even if the server is already closed', async () => { | ||
const server = net.createServer(); | ||
const timeoutRef = setTimeout(common.mustNotCall(), 2 ** 31 - 1); | ||
|
||
server.listen(0, common.mustCall(async () => { | ||
await server[Symbol.asyncDispose]().then(common.mustCall()); | ||
await server[Symbol.asyncDispose]().then(common.mustCall(), common.mustNotCall()); | ||
clearTimeout(timeoutRef); | ||
})); | ||
}); | ||
}); |