oven-sh / bun

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

Inspector crashing stdout.write #5179

Open robobun opened 10 months ago

robobun commented 10 months ago

Bun 1.0 on Fedora38

Anyone know what's happening here: Code:

console.log("Hello via Bun!");
const prompt = "Type something: ";
process.stdout.write(prompt);
for await (const line of console) {
  console.log(`You typed: ${''+line}`);
  process.stdout.write(prompt);
  if(line === 'q') break;
}

It crashes when inspecting, but no crash without inspection: $ bun --inspect index.ts Out:

Hello via Bun!
Type something: asd
You typed: asd
1 | console.log("Hello via Bun!");
2 | const prompt = "Type something: ";
3 | process.stdout.write(prompt);
4 | for await (const line of console) {
5 |   console.log(`You typed: ${''+line}`);
6 |   process.stdout.write(''+prompt);
                          ^
TypeError: Cannot convert a symbol to a string

Originally reported on Discord: Inspector crashing stdout.write

nektro commented 2 months ago

does this still reproduce for you? it appears to be working now in Bun 1.1.9 (you may need to run bun upgrade)

Soarex16 commented 2 weeks ago

Hello @nektro! I can still reproduce this issue with the following example:

console.log("Hello via Bun!");
console.log("Start"); // breakpoint

const x = Symbol("test");
console.log(x);
console.log(x);
console.log(x);
console.log(x);
console.log(x); // breakpoint

If I resume the program after the first breakpoint hit it will stop with an exception:

image