oven-sh / bun

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

String.replace() crashes in `bun repl` on Windows #11493

Open letmutex opened 4 months ago

letmutex commented 4 months ago

What version of Bun is running?

1.1.10

What platform is your computer?

Microsoft Windows NT 10.0.19045.0 x64

What steps can reproduce the bug?

Run the following code using bun repl on Windows 10:

"abc".replace("a", "x")

What is the expected behavior?

Prints 'xbc'

What do you see instead?

A crash with the following log:

Welcome to Bun v1.1.10
[!] Please note that the REPL implementation is still experimental!
    Don't consider it to be representative of the stability or behavior of Bun overall.
> "abc".replace("a", "x")
481 |                 return SafeInspect(v, this.repl?.writer?.options ?? { colors: ${Bun.enableANSIColors}, showProxy: true });
482 |             }`,
483 |             arguments: [remoteObj],
484 |         });
485 |         ReflectDeleteProperty(GLOBAL, REPL_INTERNALS);
486 |         if (inspected.wasThrown) throw new EvalError(`Failed to inspect object: ${JSONStringify(inspected)}`);
                                             ^
EvalError: Failed to inspect object: {"result":{"type":"object","objectId":"{\"injectedScriptId\":1,\"id\":2}","subtype":"error","className":"SyntaxError","description":"SyntaxError: The only valid numeric escape in strict mode is '\\0'"},"wasThrown":true}
      at C:\Users\letmutex\AppData\Local\Temp\bunx-270072409-bun-repl@latest\node_modules\bun-repl\src\repl.ts:486:40

Bun v1.1.10 (Windows x64)

Additional information

It works in Node and also works on Linux

cubedhuang commented 3 months ago

this also happens to me if i submit Bun and it tries to inspect the Bun object; also on windows

Jarred-Sumner commented 3 months ago

@cubedhuang can you paste the contents of process.env?

cubedhuang commented 3 months ago

image this also fails

Jarred-Sumner commented 3 months ago

@cubedhuang can you run JSON.stringify(process.env)

cubedhuang commented 3 months ago

image

same error

FWIW, any string fails:

image

Jarred-Sumner commented 3 months ago

does your username or path contain any non-ascii characters?

cubedhuang commented 3 months ago

undefined, null, and booleans also result in the same error, but numbers don't

this is being run in C:\Users\99dan\Desktop

my environment variable PATH doesn't have any non-ascii characters