mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-22 06:42:19 +03:00
fix(sse): default crash-guard logger to console.warn, not console (#12042)
Real production incident (2026-08-29): the crash guard #11556 introduced defaulted its logger to `log ?? console` — console is an object, not a function, so a burst of client aborts (ECONNRESET) reaching the process-level guard threw TypeError inside the uncaughtException handler itself and killed the server, twice in three minutes. Fix: default to console.warn.bind(console). Bug-injection round trip confirms the new test fails on the old default and passes on the fix. Existing guard suite stays green: 9/9 (verified together with the new test).
This commit is contained in:
@@ -117,7 +117,10 @@ export function installProcessCrashGuard(log) {
|
||||
if (crashGuardInstalled) return;
|
||||
crashGuardInstalled = true;
|
||||
|
||||
const logger = log ?? console;
|
||||
// `console` is an object, not a callable: `log ?? console` followed by
|
||||
// `logger("warn", ...)` throws TypeError and kills the process on the very
|
||||
// abort the guard exists to swallow. Default to console.warn as a function.
|
||||
const logger = typeof log === "function" ? log : console.warn.bind(console);
|
||||
|
||||
process.on("uncaughtException", (err, origin) => {
|
||||
if (shouldSwallowUncaught(err, origin)) {
|
||||
|
||||
Reference in New Issue
Block a user