Reduce memory usage in long-running processes (#14885)

This commit is contained in:
Jarred Sumner
2024-10-29 12:56:10 -07:00
committed by GitHub
parent d5f9978007
commit b5a73130ad
16 changed files with 120 additions and 60 deletions

View File

@@ -556,6 +556,12 @@ function expectBundled(
let root = path.join(
tempDirectory,
id
.replaceAll("\\", "/")
.replaceAll(":", "-")
.replaceAll(" ", "-")
.replaceAll("\r\n", "-")
.replaceAll("\n", "-")
.replaceAll(".", "-")
.split("/")
.map(a => filenamify(a))
.join("/"),

View File

@@ -79,7 +79,7 @@ async function getDevServerURL() {
readStream()
.catch(e => reject(e))
.finally(() => {
dev_server.unref?.();
dev_server?.unref?.();
});
await promise;
return baseUrl;

View File

@@ -15,15 +15,18 @@ describe("doesnt_crash", async () => {
files = readdirSync(files_dir).map(file => path.join(files_dir, file));
console.log("Tempdir", temp_dir);
files.map(file => {
const outfile1 = path.join(temp_dir, file).replaceAll("\\", "/");
const outfile2 = path.join(temp_dir, "lmao1-" + file).replaceAll("\\", "/");
const outfile3 = path.join(temp_dir, "lmao2-" + file).replaceAll("\\", "/");
const outfile4 = path.join(temp_dir, "lmao3-" + file).replaceAll("\\", "/");
files.map(absolute => {
absolute = absolute.replaceAll("\\", "/");
const file = path.basename(absolute);
const outfile1 = path.join(temp_dir, "file-1" + file).replaceAll("\\", "/");
const outfile2 = path.join(temp_dir, "file-2" + file).replaceAll("\\", "/");
const outfile3 = path.join(temp_dir, "file-3" + file).replaceAll("\\", "/");
const outfile4 = path.join(temp_dir, "file-4" + file).replaceAll("\\", "/");
test(file, async () => {
{
const { stdout, stderr, exitCode } =
await Bun.$`${bunExe()} build --experimental-css ${file} --outfile=${outfile1}`.quiet().env(bunEnv);
await Bun.$`${bunExe()} build --experimental-css ${absolute} --outfile=${outfile1}`.quiet().env(bunEnv);
expect(exitCode).toBe(0);
expect(stdout.toString()).not.toContain("error");
expect(stderr.toString()).toBeEmpty();
@@ -39,7 +42,9 @@ describe("doesnt_crash", async () => {
test(`(minify) ${file}`, async () => {
{
const { stdout, stderr, exitCode } =
await Bun.$`${bunExe()} build --experimental-css ${file} --minify --outfile=${outfile3}`.quiet().env(bunEnv);
await Bun.$`${bunExe()} build --experimental-css ${absolute} --minify --outfile=${outfile3}`
.quiet()
.env(bunEnv);
expect(exitCode).toBe(0);
expect(stdout.toString()).not.toContain("error");
expect(stderr.toString()).toBeEmpty();