-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Open
Labels
Description
What version of Bun is running?
1.3.10+30e609e08
What platform is your computer?
Darwin 25.3.0 arm64 arm
What steps can reproduce the bug?
import { expect, test } from "bun:test";
test("413 responses should include a Date header", async () => {
using server = Bun.serve({
port: 0,
maxRequestBodySize: 1,
fetch() {
return new Response("Hello Bun");
},
});
const res = await fetch({
url: `http://localhost:${server.port}/`,
method: "POST",
body: "12",
});
expect(res.status).toBe(413);
expect(res.headers.get("date")).not.toBeNull();
});What is the expected behavior?
$ bun test ./repro.ts
bun test v1.3.10 (30e609e0)
repro.ts:
✓ 413 responses should include a Date header [10.27ms]
1 pass
0 fail
2 expect() calls
Ran 1 test across 1 file. [127.00ms]What do you see instead?
$ bun test ./repro.ts
bun test v1.3.10 (30e609e0)
repro.ts:
12 | url: `http://localhost:${server.port}/`,
13 | method: "POST",
14 | body: "12",
15 | });
16 | expect(res.status).toBe(413);
17 | expect(res.headers.get("date")).not.toBeNull();
^
error: expect(received).not.toBeNull()
Received: null
at <anonymous> (/<redacted>/repro.ts:17:41)
✗ 413 responses should include a Date header [11.93ms]
0 pass
1 fail
2 expect() calls
Ran 1 test across 1 file. [115.00ms]Additional information
According to the spec:
An origin server with a clock (as defined in Section 5.6.7) MUST generate a Date header field in all 2xx (Successful), 3xx (Redirection), and 4xx (Client Error) responses, and MAY generate a Date header field in 1xx (Informational) and 5xx (Server Error) responses.
Reactions are currently unavailable