openclaw - 💡(How to fix) Fix [aight-utils] Bootstrap hook re-registered on every hot-reload (duplicate api.on accumulation) [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#62293Fetched 2026-04-08 03:06:31
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

aight-utils plugin's registerBootstrap() function calls api.on("before_agent_start", ...) without any idempotency guard. Every gateway hot-reload (config change) triggers register() again, causing the hook to accumulate indefinitely.

Root Cause

dist/src/bootstrap.jsregisterBootstrap(api) has no guard:

// CURRENT (buggy)
export function registerBootstrap(api) {
    api.on("before_agent_start", (_event, ctx) => { ... });
}

Fix Action

Fix

Add a module-level flag:

let _bootstrapRegistered = false;
export function registerBootstrap(api) {
    if (_bootstrapRegistered) {
        api.logger.info("[aight-utils] Bootstrap hook already registered, skipping.");
        return;
    }
    _bootstrapRegistered = true;
    api.on("before_agent_start", (_event, ctx) => { ... });
}

Applied this patch locally to ~/.openclaw/extensions/aight-utils/dist/src/bootstrap.js — confirmed working.

Code Example

// CURRENT (buggy)
export function registerBootstrap(api) {
    api.on("before_agent_start", (_event, ctx) => { ... });
}

---

let _bootstrapRegistered = false;
export function registerBootstrap(api) {
    if (_bootstrapRegistered) {
        api.logger.info("[aight-utils] Bootstrap hook already registered, skipping.");
        return;
    }
    _bootstrapRegistered = true;
    api.on("before_agent_start", (_event, ctx) => { ... });
}
RAW_BUFFERClick to expand / collapse

Summary

aight-utils plugin's registerBootstrap() function calls api.on("before_agent_start", ...) without any idempotency guard. Every gateway hot-reload (config change) triggers register() again, causing the hook to accumulate indefinitely.

Version

  • aight-utils: 0.1.21
  • OpenClaw: 2026.3.31

Steps to Reproduce

  1. Enable aight-utils plugin
  2. Trigger any gateway hot-reload (e.g., change any config via UI)
  3. Observe logs: [aight-utils] Attempting to register bootstrap hook... + Plugin loaded repeats on each reload

Impact

  • Gateway logs accumulate thousands of duplicate entries (967 in one day on our instance)
  • Multiple identical before_agent_start hooks registered; each session start triggers N hook calls instead of 1
  • Memory/CPU overhead grows over time proportional to reload count

Root Cause

dist/src/bootstrap.jsregisterBootstrap(api) has no guard:

// CURRENT (buggy)
export function registerBootstrap(api) {
    api.on("before_agent_start", (_event, ctx) => { ... });
}

Fix

Add a module-level flag:

let _bootstrapRegistered = false;
export function registerBootstrap(api) {
    if (_bootstrapRegistered) {
        api.logger.info("[aight-utils] Bootstrap hook already registered, skipping.");
        return;
    }
    _bootstrapRegistered = true;
    api.on("before_agent_start", (_event, ctx) => { ... });
}

Applied this patch locally to ~/.openclaw/extensions/aight-utils/dist/src/bootstrap.js — confirmed working.

extent analysis

TL;DR

Apply a patch to the registerBootstrap function in aight-utils to add an idempotency guard, preventing duplicate registrations of the before_agent_start hook.

Guidance

  • Identify the registerBootstrap function in dist/src/bootstrap.js and add a module-level flag _bootstrapRegistered to track whether the hook has already been registered.
  • Modify the registerBootstrap function to check the _bootstrapRegistered flag before registering the hook, and skip registration if the flag is already set to true.
  • Verify the fix by triggering a gateway hot-reload and checking the logs for duplicate entries.
  • Consider applying this patch to the aight-utils plugin in a production environment to prevent further log accumulation and performance issues.

Example

let _bootstrapRegistered = false;
export function registerBootstrap(api) {
    if (_bootstrapRegistered) {
        api.logger.info("[aight-utils] Bootstrap hook already registered, skipping.");
        return;
    }
    _bootstrapRegistered = true;
    api.on("before_agent_start", (_event, ctx) => { ... });
}

Notes

This fix assumes that the registerBootstrap function is only called once per gateway hot-reload. If this function can be called multiple times in other scenarios, additional modifications may be necessary.

Recommendation

Apply the workaround by patching the registerBootstrap function with the idempotency guard, as this will prevent duplicate registrations and mitigate the performance issues caused by the bug.

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 [aight-utils] Bootstrap hook re-registered on every hot-reload (duplicate api.on accumulation) [1 participants]