oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.4k stars 2.78k forks source link

bun crashes on "long" (recursive) iterations #15254

Open Tomato6966 opened 6 days ago

Tomato6966 commented 6 days ago

What version of Bun is running?

1.1.34+5e5e7c60f

What platform is your computer?

5.15.167.4-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

When running a file.ts which scans readdir("path", { recursive }) and then map over all result strings to add the "path" infront, bun doesn't complete the map

import { readdir } from "node:fs/promises";

export const walks = async (path:string, recursive = true):Promise<string[]> => {
    let files = [];
    const items = await readdir(path, { withFileTypes: true });
    if(!items) throw new Error(`No items in ${path}`);
    for (let i = 0, m = items.length; i < m; ++i) {
        if(items[i].isDirectory()) {
            if (recursive) files = [ ...files, ...(await walks(`${path}/${items[i].name}`)) ]
        } else if(items[i].isFile()) {
            files.push(`${path}/${items[i].name}`)
        }
    }
    return files;
};

I'm on ubuntu 22 via wsl

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

Tomato6966 commented 5 days ago

It's because when i initialize those ELs:

    process.on('SIGINT', () => process.exit());
    process.on('SIGUSR1', () => process.exit());
    process.on('SIGUSR2', () => process.exit());

It seems like it's only because of this: SIGUSR1

Jarred-Sumner commented 5 days ago

We probably need to disable SIGUSR1. SIGUSR1 is used by the GC to signal collection