SIGN IN SIGN UP

fix(emulator): stringify send() errors before writing them to stderr (#10905)

* fix(emulator): stringify send() errors before writing them to stderr

EmulatorLog.flush() passed the Error object from process.send()'s
callback straight to process.stderr.write(), which accepts only a
string, Buffer, TypedArray, or DataView. Writing an Error makes
write() throw synchronously, and it does so inside a callback with no
surrounding try/catch -- an uncaught exception.

The cost is diagnostic and it compounds: this path only runs when the
IPC channel to the functions runtime has already failed, so the error
that gets destroyed is the one explaining why the runtime became
unreachable, and what operators see instead is a TypeError about
stream chunk types pointing at Node's stream internals.

Fixes #10876

* Update src/emulator/types.ts

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* fix(emulator): restore the send() call and drop the unneeded any cast

Applying the buffer-clearing suggestion removed the process.send() call
line itself along with its callback, leaving the if (err) body and its
closing brace behind, so the file no longer compiled.

Restore the call without the `as any` cast. @types/node declares
send(message, sendHandle?, options?, callback?) with the callback
overload, so the cast is unnecessary and the comment claiming otherwise
was stale; typing the callback parameter Error | null typechecks
cleanly. The node docs link is kept as the reference for that signature.

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Joe Hanley <joehanley@google.com>
M
Matt Sears committed
e2d31c1b1bc9714d45af1ec014c634e605b0fd76
Parent: cc177a3
Committed by GitHub <noreply@github.com> on 9/1/2026, 4:05:53 PM