mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
29 lines
792 B
JavaScript
Generated
29 lines
792 B
JavaScript
Generated
// This test is meant to cause OOM if either:
|
|
//
|
|
// - the response body leaks
|
|
// - the headers leak
|
|
//
|
|
|
|
const buf = new Uint8Array(1024 * 1024 * 32);
|
|
|
|
for (var i = 0; i < 1000; i++) {
|
|
try {
|
|
new Response(buf, {
|
|
// This causes the response constructor to throw an error
|
|
statusText: Symbol("leaky-error"),
|
|
|
|
status: 200,
|
|
headers: {
|
|
// That means the string needs to be long enough to otherwise show up with a 0-length body.
|
|
["Content-Type"]:
|
|
"yo de lay yo de lay yo de lay yo de lay yo de lay yo de lay ".repeat(1024) + Math.random(),
|
|
},
|
|
});
|
|
} catch (e) {}
|
|
}
|
|
Bun.gc(true);
|
|
console.log("RSS:", (process.memoryUsage().rss / 1024 / 1024) | 0, "MB");
|
|
if (process.memoryUsage.rss() > 1024 * 1024 * 1024) {
|
|
process.exit(1);
|
|
}
|