-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
What version of Bun is running?
1.3.10+30e609e08
What platform is your computer?
Darwin 25.3.0 arm64 arm
What steps can reproduce the bug?
Create test.js with a literal null byte (0x00) between the backticks:
const s = String.raw``;
console.log("length:", s.length);
console.log("charCode[0]:", s.charCodeAt(0));Run with bun test.js and node test.js.
What is the expected behavior?
length: 1
charCode[0]: 0
A null byte in a template literal should be preserved as-is, matching Node v22.22.0 behavior.
What do you see instead?
length: 6
charCode[0]: 92
Bun outputs the 6-character literal string \uFFFD (\, u, F, F, F, D) instead of a single null byte.
Additional information
Bun version: 1.3.10+30e609e08
Node version: v22.22.0 (reference)
Ran into this with wasm-audio-decoders, which uses simple-yenc to embed WASM binaries as yEncoded strings in template literals, decoded at runtime via String.raw. Every decoder (mpg123-decoder, flac, ogg-vorbis) failed with a CRC mismatch because null bytes in the payload were being corrupted by the transpiler.
Workaround was applied in simple-yenc (escape null bytes on encode, treat 0xFFFD as 0x00 on decode) but the root cause is in Bun.