aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/node-http.test.ts
diff options
context:
space:
mode:
authorGravatar Ciro Spaciari <ciro.spaciari@gmail.com> 2023-02-27 21:24:59 -0300
committerGravatar GitHub <noreply@github.com> 2023-02-27 16:24:59 -0800
commit4b627457540c7c6ef79e7133672e282bb0e61702 (patch)
treeeb7e95f56b9d2b655db6b227ccb7a085cfa4d47a /test/bun.js/node-http.test.ts
parent0afb1693d370c0dd1340b3eb7659d31ef3fc94a3 (diff)
downloadbun-4b627457540c7c6ef79e7133672e282bb0e61702.tar.gz
bun-4b627457540c7c6ef79e7133672e282bb0e61702.tar.zst
bun-4b627457540c7c6ef79e7133672e282bb0e61702.zip
add signal on http.Server.listen (#2223)
* add signal on http.Server.listen * actual call close instead of just stopping the server
Diffstat (limited to 'test/bun.js/node-http.test.ts')
-rw-r--r--test/bun.js/node-http.test.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/bun.js/node-http.test.ts b/test/bun.js/node-http.test.ts
index b3ab4072b..3ba383c2e 100644
--- a/test/bun.js/node-http.test.ts
+++ b/test/bun.js/node-http.test.ts
@@ -352,6 +352,32 @@ describe("node:http", () => {
});
});
+ describe("signal", () => {
+
+ it("should abort and close the server", done => {
+ const server = createServer((req, res) => {
+ res.writeHead(200, { "Content-Type": "text/plain" });
+ res.end("Hello World");
+ });
+
+ //force timeout to not hang tests
+ const interval = setTimeout(()=> {
+ expect(false).toBe(true);
+ server.close();
+ done()
+ }, 100);
+
+ const signal = AbortSignal.timeout(30);
+ signal.addEventListener("abort", ()=> {
+ clearTimeout(interval);
+ expect(true).toBe(true);
+ done()
+ });
+
+ server.listen({ signal, port: 8130 });
+ });
+ });
+
describe("get", () => {
let server;
beforeAll(() => {