openclaw - 💡(How to fix) Fix Bug: hal-startup hook timers can block lifecycle closure [1 comments, 1 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#71688Fetched 2026-04-26 05:09:47
View on GitHub
Comments
1
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
closed ×1commented ×1

The internal startup hook hal-startup scheduled delayed and periodic timers without calling unref(). In lifecycle paths where completion depends on event-loop quiescence, this can keep hook execution alive and block task/hook closure semantics even after user-visible work is complete.

Root Cause

The internal startup hook hal-startup scheduled delayed and periodic timers without calling unref(). In lifecycle paths where completion depends on event-loop quiescence, this can keep hook execution alive and block task/hook closure semantics even after user-visible work is complete.

Code Example

[hal-startup] Startup message delivered
(Observed alongside closure-blocking behaviour before timer unref fix)
RAW_BUFFERClick to expand / collapse

Reporting Agent: GitHub Copilot Session ID: platform-infra-2026-04-25 Component: gateway/hooks Severity: High

Description

The internal startup hook hal-startup scheduled delayed and periodic timers without calling unref(). In lifecycle paths where completion depends on event-loop quiescence, this can keep hook execution alive and block task/hook closure semantics even after user-visible work is complete.

Reproducible Steps

  1. Enable the internal hal-startup hook.
  2. Restart the gateway.
  3. Observe hook schedules a perpetual setInterval and delayed setTimeouts.
  4. In closure-sensitive paths, completion can remain blocked despite requirements being met.

Expected Behaviour

Startup hook runs and exits without retaining references that block lifecycle closure.

Actual Behaviour

Hook uses referenced timers, which can hold event loop activity and interfere with clean closure.

Environment

  • OS: Linux (xps15-9520)
  • OpenClaw version: 2026.4.23 (a979721)
  • Branch/channel: main

Logs / Stack Trace

<details> <summary>Click to expand</summary>
[hal-startup] Startup message delivered
(Observed alongside closure-blocking behaviour before timer unref fix)
</details>

Suggested Fix (optional)

In hooks/hal-startup/handler.ts, call unref() on the delayed setTimeout handles and the long-running setInterval handle.

extent analysis

TL;DR

Call unref() on the delayed setTimeout handles and the long-running setInterval handle in the hal-startup hook to prevent blocking lifecycle closure.

Guidance

  • Review the handler.ts file in the hooks/hal-startup directory to locate the creation of setTimeout and setInterval timers.
  • Verify that unref() is called on these timer handles to prevent them from keeping the event loop active.
  • Test the fix by restarting the gateway and observing whether the hook execution completes without blocking lifecycle closure.
  • Consider adding logging or debugging statements to monitor the behavior of the hal-startup hook and verify that the fix is effective.

Example

// In handler.ts
const timeoutId = setTimeout(() => {
  // handler code
}, 1000);
timeoutId.unref(); // Add this line to unref the timeout handle

const intervalId = setInterval(() => {
  // handler code
}, 1000);
intervalId.unref(); // Add this line to unref the interval handle

Notes

This fix assumes that the unref() method is available and correctly implemented for the timer handles. If issues persist, further debugging may be necessary to identify other potential causes of blocked lifecycle closure.

Recommendation

Apply the suggested fix by calling unref() on the timer handles, as this directly addresses the identified cause of the problem and is a targeted solution.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Bug: hal-startup hook timers can block lifecycle closure [1 comments, 1 participants]