fix(whatsapp): reconnect on crypto unhandled rejection

This commit is contained in:
Peter Steinberger
2026-01-05 13:55:37 +00:00
parent 7619534bc0
commit f24fe4e9cd
4 changed files with 114 additions and 23 deletions

View File

@@ -27,6 +27,7 @@ import {
PortInUseError,
} from "./infra/ports.js";
import { assertSupportedRuntime } from "./infra/runtime-guard.js";
import { isUnhandledRejectionHandled } from "./infra/unhandled-rejections.js";
import { enableConsoleCapture } from "./logging.js";
import { runCommandWithTimeout, runExec } from "./process/exec.js";
import { monitorWebProvider } from "./provider-web.js";
@@ -79,6 +80,7 @@ if (isMain) {
// Global error handlers to prevent silent crashes from unhandled rejections/exceptions.
// These log the error and exit gracefully instead of crashing without trace.
process.on("unhandledRejection", (reason, _promise) => {
if (isUnhandledRejectionHandled(reason)) return;
console.error(
"[clawdbot] Unhandled promise rejection:",
reason instanceof Error ? (reason.stack ?? reason.message) : reason,