mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-30 07:14:39 +08:00
Node's WriteStream constructor calls setDefaultEncoding after the Writable constructor has scheduled _construct, so with encoding: 'buffer' it throws ERR_UNKNOWN_ENCODING but the unreachable stream still opens its file on a later tick, creating it, and with the default 'w' flags truncating it. The runtime threw before scheduling the open; it now constructs the stream first, as Node does. Corpus 5547 ran that check on the file its other blocks write, so the late truncation raced with the fd block's write and Node's own output changed with the timing (it printed an empty file on macOS). The check now uses its own file, and the program prints that the file was created.