diff options
author | 2022-09-22 02:25:32 -0700 | |
---|---|---|
committer | 2022-09-22 02:25:32 -0700 | |
commit | ce9daa48572a345ffd95e41d9f64b9e4719a88fa (patch) | |
tree | d3a6198f4c17e4afe3edb403efc9eea08212a589 /test/bun.js/serve.test.ts | |
parent | e15fb6b9b220510df049e782d4f2f6eb3150d069 (diff) | |
download | bun-ce9daa48572a345ffd95e41d9f64b9e4719a88fa.tar.gz bun-ce9daa48572a345ffd95e41d9f64b9e4719a88fa.tar.zst bun-ce9daa48572a345ffd95e41d9f64b9e4719a88fa.zip |
1 event loop per thread. Instead of 3.
uWebSockets and uSockets will need to be upgraded to match the changes.
Previously:
- Bun had a separate kqueue/eventfd just for async wakeups.
- Bun had a separate kqueue/epoll just for reading files non-blocking in the same thread
This commit unifies it into one event loop per thread
Diffstat (limited to 'test/bun.js/serve.test.ts')
-rw-r--r-- | test/bun.js/serve.test.ts | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/test/bun.js/serve.test.ts b/test/bun.js/serve.test.ts index 95428c028..317d94100 100644 --- a/test/bun.js/serve.test.ts +++ b/test/bun.js/serve.test.ts @@ -39,7 +39,9 @@ describe("streaming", () => { }, }); - const response = await fetch(`http://127.0.0.1:${server.port}`); + const response = await fetch( + `http://${server.hostname}:${server.port}` + ); if (response.status > 0) { expect(response.status).toBe(500); expect(await response.text()).toBe("fail"); @@ -77,7 +79,9 @@ describe("streaming", () => { }, }); - const response = await fetch(`http://127.0.0.1:${server.port}`); + const response = await fetch( + `http://${server.hostname}:${server.port}` + ); // connection terminated if (response.status > 0) { expect(response.status).toBe(200); @@ -110,7 +114,7 @@ describe("streaming", () => { }, }); - const response = await fetch(`http://127.0.0.1:${server.port}`); + const response = await fetch(`http://${server.hostname}:${server.port}`); const text = await response.text(); expect(text.length).toBe(textToExpect.length); expect(text).toBe(textToExpect); @@ -134,7 +138,7 @@ describe("streaming", () => { ); }, }); - const response = await fetch(`http://127.0.0.1:${server.port}`); + const response = await fetch(`http://${server.hostname}:${server.port}`); expect(await response.text()).toBe(textToExpect); server.stop(); }); @@ -157,8 +161,18 @@ describe("streaming", () => { }, }); - const response = await fetch(`http://127.0.0.1:${server.port}`); - expect(response.status).toBe(500); + var response; + try { + response = await fetch(`http://${server.hostname}:${server.port}`); + } catch (e) { + if (e.name !== "ConnectionClosed") { + throw e; + } + } + + if (response) { + expect(response.status).toBe(500); + } } catch (e) { if (!e || !(e instanceof TestPass)) { throw e; @@ -191,7 +205,7 @@ describe("streaming", () => { }, }); - const response = await fetch(`http://127.0.0.1:${server.port}`); + const response = await fetch(`http://${server.hostname}:${server.port}`); expect(response.status).toBe(500); expect(await response.text()).toBe("Fail"); expect(pass).toBe(true); @@ -222,7 +236,7 @@ describe("streaming", () => { ); }, }); - const response = await fetch(`http://127.0.0.1:${server.port}`); + const response = await fetch(`http://${server.hostname}:${server.port}`); expect(await response.text()).toBe(textToExpect); server.stop(); }); @@ -244,7 +258,7 @@ describe("streaming", () => { ); }, }); - const response = await fetch(`http://127.0.0.1:${server.port}`); + const response = await fetch(`http://${server.hostname}:${server.port}`); const text = await response.text(); expect(text).toBe(textToExpect); server.stop(); @@ -270,7 +284,7 @@ describe("streaming", () => { ); }, }); - const response = await fetch(`http://127.0.0.1:${server.port}`); + const response = await fetch(`http://${server.hostname}:${server.port}`); expect(await response.text()).toBe(textToExpect); server.stop(); }); @@ -295,7 +309,7 @@ describe("streaming", () => { ); }, }); - const response = await fetch(`http://127.0.0.1:${server.port}`); + const response = await fetch(`http://${server.hostname}:${server.port}`); expect(await response.text()).toBe(textToExpect); server.stop(); }); @@ -324,7 +338,7 @@ describe("streaming", () => { ); }, }); - const response = await fetch(`http://127.0.0.1:${server.port}`); + const response = await fetch(`http://${server.hostname}:${server.port}`); expect(await response.text()).toBe(textToExpect); server.stop(); }); @@ -337,7 +351,7 @@ it("should work for a hello world", async () => { return new Response(`Hello, world!`); }, }); - const response = await fetch(`http://127.0.0.1:${server.port}`); + const response = await fetch(`http://${server.hostname}:${server.port}`); expect(await response.text()).toBe("Hello, world!"); server.stop(); }); @@ -352,7 +366,7 @@ it("should work for a blob", async () => { return new Response(new Blob([textToExpect])); }, }); - const response = await fetch(`http://127.0.0.1:${server.port}`); + const response = await fetch(`http://${server.hostname}:${server.port}`); expect(await response.text()).toBe(textToExpect); server.stop(); }); @@ -367,7 +381,7 @@ it("should work for a blob stream", async () => { return new Response(new Blob([textToExpect]).stream()); }, }); - const response = await fetch(`http://127.0.0.1:${server.port}`); + const response = await fetch(`http://${server.hostname}:${server.port}`); expect(await response.text()).toBe(textToExpect); server.stop(); }); @@ -382,7 +396,7 @@ it("should work for a file", async () => { return new Response(file(fixture)); }, }); - const response = await fetch(`http://127.0.0.1:${server.port}`); + const response = await fetch(`http://${server.hostname}:${server.port}`); expect(await response.text()).toBe(textToExpect); server.stop(); }); @@ -397,7 +411,7 @@ it("should work for a file stream", async () => { return new Response(file(fixture).stream()); }, }); - const response = await fetch(`http://127.0.0.1:${server.port}`); + const response = await fetch(`http://${server.hostname}:${server.port}`); expect(await response.text()).toBe(textToExpect); server.stop(); }); @@ -416,7 +430,7 @@ it("fetch should work with headers", async () => { }); }, }); - const response = await fetch(`http://127.0.0.1:${server.port}`, { + const response = await fetch(`http://${server.hostname}:${server.port}`, { headers: { "X-Foo": "bar", }, @@ -444,7 +458,7 @@ it(`should work for a file ${count} times serial`, async () => { // it's hard to say if this only happens here due to some weird stuff with the test runner // or if it's "real" issue for (let i = 0; i < count; i++) { - const response = await fetch(`http://127.0.0.1:${server.port}`); + const response = await fetch(`http://${server.hostname}:${server.port}`); expect(await response.text()).toBe(textToExpect); } @@ -467,7 +481,7 @@ it(`should work for text ${count} times serial`, async () => { // it's hard to say if this only happens here due to some weird stuff with the test runner // or if it's "real" issue for (let i = 0; i < count; i++) { - const response = await fetch(`http://127.0.0.1:${server.port}`); + const response = await fetch(`http://${server.hostname}:${server.port}`); expect(await response.text()).toBe(textToExpect); } @@ -488,7 +502,7 @@ it(`should work for ArrayBuffer ${count} times serial`, async () => { // it's hard to say if this only happens here due to some weird stuff with the test runner // or if it's "real" issue for (let i = 0; i < count; i++) { - const response = await fetch(`http://127.0.0.1:${server.port}`); + const response = await fetch(`http://${server.hostname}:${server.port}`); expect(await response.text()).toBe(textToExpect); } |