Skip to content

Regex works in Node.js but not in Bun #17970

@SamyPesse

Description

@SamyPesse

What version of Bun is running?

1.2.4+fd9a5ea66

What platform is your computer?

Darwin 24.3.0 arm64 arm

What steps can reproduce the bug?

Run the following code using node and bun, you can observe that Node.js returns a result for the regex, while in bun, it logs null:

(async () => {
    const res = await fetch('https://raw.githubusercontent.com/GitbookIO/integrations/c26e594ca86bc75eaa18c4cda995dab56e21008a/integrations/arcade/assets/arcade-preview.png');
    const content = await res.arrayBuffer();
    const base64 = Buffer.from(content).toString('base64');

    const byteRegexp = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;

    console.log(base64.match(byteRegexp));
})()

This regex might not be correct, but it should still return the same value.

What is the expected behavior?

Both Node.js and Bun should return the same results.

What do you see instead?

Bun returns null.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingconfirmed bugWe can reproduce this issuejscRelated to an issue in JavaScriptCorenode.jsCompatibility with Node.js APIsregression

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions