mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Co-authored-by: nektro <nektro@users.noreply.github.com> Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
22 lines
801 B
TypeScript
22 lines
801 B
TypeScript
import { test, expect } from "bun:test";
|
|
import { writeFileSync, mkdirSync } from "node:fs";
|
|
import { join } from "path";
|
|
import { bunEnv, bunExe, tmpdirSync } from "harness";
|
|
|
|
test("long chain of expressions does not cause stack overflow", () => {
|
|
const chain = `globalThis.a = {};` + "\n" + `globalThis.a + globalThis.a +`.repeat(1000000) + `globalThis.a` + "\n";
|
|
const temp_dir = tmpdirSync();
|
|
mkdirSync(temp_dir, { recursive: true });
|
|
writeFileSync(join(temp_dir, "index.js"), chain, "utf-8");
|
|
const { exitCode } = Bun.spawnSync({
|
|
cmd: [bunExe(), "build", "--no-bundle", join(temp_dir, "index.js")],
|
|
cwd: import.meta.dir,
|
|
env: bunEnv,
|
|
stderr: "inherit",
|
|
stdout: Bun.file("/dev/null"),
|
|
stdin: Bun.file("/dev/null"),
|
|
});
|
|
|
|
expect(exitCode).toBe(0);
|
|
}, 1000000);
|