mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 12:51:54 +00:00
Test
This commit is contained in:
@@ -5,11 +5,13 @@ const server = createServer((req, res) => {
|
||||
throw new Error("Oops!");
|
||||
});
|
||||
|
||||
server.listen({ port: 0 }, async (err, host, port) => {
|
||||
server.listen({ port: 0 }, async err => {
|
||||
const { port, address: host } = server.address();
|
||||
if (err) {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
const hostname = isIPv6(host) ? `[${host}]` : host;
|
||||
process.send(`http://${hostname}:${port}/`);
|
||||
|
||||
(process?.connected ? process.send : console.log)(`http://${hostname}:${port}/`);
|
||||
});
|
||||
|
||||
@@ -2,13 +2,13 @@ import { spawn } from "bun";
|
||||
import { expect, test } from "bun:test";
|
||||
import { bunEnv, bunExe } from "harness";
|
||||
|
||||
test("node:http should not crash when server throws", async () => {
|
||||
test("node:http should not crash when server throws, and should abruptly close the socket", async () => {
|
||||
const { promise, resolve, reject } = Promise.withResolvers();
|
||||
await using server = spawn({
|
||||
cwd: import.meta.dirname,
|
||||
cmd: [bunExe(), "04298.fixture.js"],
|
||||
env: bunEnv,
|
||||
stderr: "pipe",
|
||||
stderr: "inherit",
|
||||
ipc(url) {
|
||||
resolve(url);
|
||||
},
|
||||
@@ -20,5 +20,4 @@ test("node:http should not crash when server throws", async () => {
|
||||
});
|
||||
const url = await promise;
|
||||
const response = await fetch(url);
|
||||
expect(response.status).toBe(500);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user