diff options
Diffstat (limited to 'test/js')
-rw-r--r-- | test/js/bun/http/big-form-data.fixture.js | 20 | ||||
-rw-r--r-- | test/js/bun/http/bun-server.test.ts | 11 |
2 files changed, 31 insertions, 0 deletions
diff --git a/test/js/bun/http/big-form-data.fixture.js b/test/js/bun/http/big-form-data.fixture.js new file mode 100644 index 000000000..72036a222 --- /dev/null +++ b/test/js/bun/http/big-form-data.fixture.js @@ -0,0 +1,20 @@ +const content = "Bun".repeat(15360000); + +const server = Bun.serve({ + port: 0, + fetch: async req => { + const data = await req.formData(); + return new Response(data.get("name") === content ? "OK" : "NO"); + }, +}); + +const formData = new FormData(); +formData.append("name", content); +const result = await fetch(`http://${server.hostname}:${server.port}`, { + method: "POST", + body: formData, +}).then(res => res.text()); + +server.stop(); + +process.exit(result === "OK" ? 0 : 1); diff --git a/test/js/bun/http/bun-server.test.ts b/test/js/bun/http/bun-server.test.ts index 3e0e4e71e..398ef4bb7 100644 --- a/test/js/bun/http/bun-server.test.ts +++ b/test/js/bun/http/bun-server.test.ts @@ -1,4 +1,5 @@ import { describe, expect, test } from "bun:test"; +import { bunExe, bunEnv } from "harness"; describe("Server", () => { test("normlizes incoming request URLs", async () => { @@ -357,4 +358,14 @@ describe("Server", () => { server.stop(true); } }); + + test("should not crash with big formData", async () => { + const proc = Bun.spawn({ + cmd: [bunExe(), "big-form-data.fixture.js"], + cwd: import.meta.dir, + env: bunEnv, + }); + await proc.exited; + expect(proc.exitCode).toBe(0); + }); }); |