openclaw - 💡(How to fix) Fix Gateway self-SIGTERMs after ~45s: server.mjs device approval timeout kills healthy gateway [3 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#51463Fetched 2026-04-08 01:10:53
View on GitHub
Comments
3
Participants
3
Timeline
3
Reactions
0
Author
Timeline (top)
commented ×3

Fix Action

Workaround

None from inside the container. The server.mjs timeout logic is baked into the Docker image.

RAW_BUFFERClick to expand / collapse

Bug

On container restart, server.mjs spawns the gateway process but kills it with SIGTERM after ~45 seconds if "device approval" does not complete in time. This causes a crash loop when combined with a watchdog auto-restart.

Environment

  • OpenClaw 2026.3.13 (61d171a)
  • Docker (Hostinger KVM VPS)
  • WhatsApp + Telegram channels configured

Steps to reproduce

  1. Restart the Docker container
  2. Gateway starts successfully — WhatsApp connects, Telegram ok
  3. ~45 seconds later, server.mjs sends SIGTERM to the gateway child process
  4. Logs show: "OpenClaw process exited before device approval could complete"
  5. External watchdog detects dead gateway, restarts container → crash loop

Evidence

  • strace confirmed SIGTERM originates from server.mjs (the parent process, si_pid matches server.mjs PID), not from any external process
  • Gateway is fully functional when killed (WhatsApp "linked", Telegram "ok", health check passes)
  • The stale gateway lock file issue (PID recycling) was a separate bug fixed independently — this timeout fires on its own
  • 25+ crashes observed overnight (2026-03-21 02:50–06:04 UTC)

Expected behavior

If the gateway is healthy and channels are connected, server.mjs should not kill it based on a device approval timeout. Either:

  1. Skip the approval timeout if channels are already connected
  2. Make the timeout configurable
  3. Check gateway health before sending SIGTERM

Workaround

None from inside the container. The server.mjs timeout logic is baked into the Docker image.

extent analysis

Fix Plan

To address the issue, we will implement a configurable device approval timeout in server.mjs. This will allow us to adjust the timeout value or skip it altogether if channels are already connected.

Step-by-Step Solution

  1. Introduce a configurable timeout:

    • Add a new environment variable DEVICE_APPROVAL_TIMEOUT to configure the timeout value.
    • Update server.mjs to read this environment variable and use its value for the timeout.
  2. Modify the timeout logic:

    • Check if channels are already connected before applying the timeout.
    • If channels are connected, either skip the timeout or set it to a very high value to prevent unnecessary restarts.

Example Code

// server.mjs
const DEVICE_APPROVAL_TIMEOUT = parseInt(process.env.DEVICE_APPROVAL_TIMEOUT) || 45000; // 45 seconds default

// ...

// Check if channels are connected
if (areChannelsConnected()) {
  // Either skip the timeout or set it to a high value
  DEVICE_APPROVAL_TIMEOUT = null; // or a very high value like 86400000 (24 hours)
}

// Apply the timeout
if (DEVICE_APPROVAL_TIMEOUT !== null) {
  setTimeout(() => {
    // Send SIGTERM to the gateway child process
    gatewayProcess.kill('SIGTERM');
  }, DEVICE_APPROVAL_TIMEOUT);
}

// ...

function areChannelsConnected() {
  // Implement logic to check if WhatsApp and Telegram channels are connected
  // Return true if connected, false otherwise
}

Verification

To verify the fix, restart the Docker container and monitor the logs. The gateway process should no longer be killed by server.mjs if channels are connected within the configured timeout period.

Extra Tips

  • Ensure that the DEVICE_APPROVAL_TIMEOUT environment variable is properly set in the Docker container.
  • Consider adding logging to track when the timeout is applied and when the gateway process is killed.
  • Review the areChannelsConnected function to ensure it accurately reflects the connection status of the channels.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

If the gateway is healthy and channels are connected, server.mjs should not kill it based on a device approval timeout. Either:

  1. Skip the approval timeout if channels are already connected
  2. Make the timeout configurable
  3. Check gateway health before sending SIGTERM

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING