openclaw - 💡(How to fix) Fix Regression: openclaw agent fails in 2026.4.5 with 'Cannot access 'n' before initialization' [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#63108Fetched 2026-04-09 07:58:27
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0

OpenClaw 2026.4.5 can fail to start openclaw agent with:

ReferenceError: Cannot access 'n' before initialization

This blocks normal agent runs and can make downstream skill-injection verification impossible.

Error Message

ReferenceError: Cannot access 'n' before initialization

Key stack segments observed:

  • dist/pi-embedded-DWASRjxE.js:7264
  • dist/message-secret-scope-3Su2G0b3.js
  • dist/target-registry-4ZVRjB-K.js
  • dist/bootstrap-registry-DSG7nIY1.js
  • dist/extensions/signal/api.js
  • dist/channel-entry-contract-DyY5TZkc.js
  • node_modules/jiti/dist/jiti.cjs

Root Cause

What was ruled out

Not caused by:

  • broken skill files
  • accounting allowlist config
  • session transcript cache
  • single-module failure in message-secret-scope-3Su2G0b3.js itself

Fix Action

Temporary workaround

A local workaround that restored openclaw agent was to disable bundled channel secret target registry discovery in:

/opt/homebrew/lib/node_modules/openclaw/dist/target-registry-4ZVRjB-K.js

By changing:

function listChannelSecretTargetRegistryEntries() {
  const entries = [];
  for (const plugin of iterateBootstrapChannelPlugins()) {
    entries.push(...plugin.secrets?.secretTargetRegistryEntries ?? []);
  }
  return entries;
}

To:

function listChannelSecretTargetRegistryEntries() {
  return [];
}

After that:

  • openclaw agent --agent accounting --message "test" --json worked again
  • runtime skill injection checks were possible again

Code Example

ReferenceError: Cannot access 'n' before initialization

---

openclaw agent --agent accounting --message "test" --json

---

node --input-type=module -e "import('/opt/homebrew/lib/node_modules/openclaw/dist/pi-embedded-DWASRjxE.js')"

---

ReferenceError: Cannot access 'n' before initialization

---

const AllMessageActions = CHANNEL_MESSAGE_ACTION_NAMES;

---

function listChannelSecretTargetRegistryEntries() {
  const entries = [];
  for (const plugin of iterateBootstrapChannelPlugins()) {
    entries.push(...plugin.secrets?.secretTargetRegistryEntries ?? []);
  }
  return entries;
}

---

function listChannelSecretTargetRegistryEntries() {
  return [];
}
RAW_BUFFERClick to expand / collapse

Summary

OpenClaw 2026.4.5 can fail to start openclaw agent with:

ReferenceError: Cannot access 'n' before initialization

This blocks normal agent runs and can make downstream skill-injection verification impossible.

Environment

  • OpenClaw: 2026.4.5
  • Node: v22.16.0
  • macOS arm64

Repro

openclaw agent --agent accounting --message "test" --json

Also reproducible with:

node --input-type=module -e "import('/opt/homebrew/lib/node_modules/openclaw/dist/pi-embedded-DWASRjxE.js')"

Error

ReferenceError: Cannot access 'n' before initialization

Key stack segments observed:

  • dist/pi-embedded-DWASRjxE.js:7264
  • dist/message-secret-scope-3Su2G0b3.js
  • dist/target-registry-4ZVRjB-K.js
  • dist/bootstrap-registry-DSG7nIY1.js
  • dist/extensions/signal/api.js
  • dist/channel-entry-contract-DyY5TZkc.js
  • node_modules/jiti/dist/jiti.cjs

What was ruled out

Not caused by:

  • broken skill files
  • accounting allowlist config
  • session transcript cache
  • single-module failure in message-secret-scope-3Su2G0b3.js itself

Single imports of some inner modules succeeded, while the full runtime path failed.

Likely cause

This looks like an initialization-order / circular-dependency regression in 2026.4.5.

Most likely chain:

  1. target-registry eagerly enumerates bundled channel plugins at module init time
  2. bundled channel loading pulls in signal/api
  3. that path re-enters pi-embedded
  4. message-tool top-level init touches CHANNEL_MESSAGE_ACTION_NAMES
  5. jiti hits TDZ on export n

The top-level line that consistently surfaced was effectively:

const AllMessageActions = CHANNEL_MESSAGE_ACTION_NAMES;

Temporary workaround

A local workaround that restored openclaw agent was to disable bundled channel secret target registry discovery in:

/opt/homebrew/lib/node_modules/openclaw/dist/target-registry-4ZVRjB-K.js

By changing:

function listChannelSecretTargetRegistryEntries() {
  const entries = [];
  for (const plugin of iterateBootstrapChannelPlugins()) {
    entries.push(...plugin.secrets?.secretTargetRegistryEntries ?? []);
  }
  return entries;
}

To:

function listChannelSecretTargetRegistryEntries() {
  return [];
}

After that:

  • openclaw agent --agent accounting --message "test" --json worked again
  • runtime skill injection checks were possible again

Suggestion

The more robust fix seems to be:

  • avoid eager bundled channel enumeration from target-registry module top-level initialization
  • make this discovery lazy, or move secret target metadata to a lighter static registration path

Happy to provide more exact traces if useful.

extent analysis

TL;DR

The most likely fix is to modify the target-registry module to avoid eager enumeration of bundled channel plugins at module init time, instead making this discovery lazy or moving secret target metadata to a lighter static registration path.

Guidance

  • Identify the target-registry module and locate the listChannelSecretTargetRegistryEntries function to understand the current implementation.
  • Consider implementing a lazy loading mechanism for bundled channel plugins to avoid initialization-order issues.
  • Review the CHANNEL_MESSAGE_ACTION_NAMES export and its dependencies to ensure it is not causing a Temporal Dead Zone (TDZ) issue.
  • Test the temporary workaround provided in the issue by modifying the listChannelSecretTargetRegistryEntries function to return an empty array, and verify if it resolves the issue.

Example

// Modified listChannelSecretTargetRegistryEntries function
function listChannelSecretTargetRegistryEntries() {
  return [];
}

This example illustrates the temporary workaround provided in the issue, which can be used as a starting point for further debugging and fixing.

Notes

The issue seems to be related to a circular dependency or initialization-order issue in the 2026.4.5 version of OpenClaw. The provided temporary workaround can help restore functionality, but a more robust fix is needed to avoid similar issues in the future.

Recommendation

Apply the workaround by modifying the listChannelSecretTargetRegistryEntries function to return an empty array, as this has been shown to restore openclaw agent functionality. However, it is recommended to investigate and implement a more robust fix to avoid eager enumeration of bundled channel plugins at module init time.

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

Temporary workaround

A local workaround that restored openclaw agent was to disable bundled channel secret target registry discovery in:

/opt/homebrew/lib/node_modules/openclaw/dist/target-registry-4ZVRjB-K.js

By changing:

function listChannelSecretTargetRegistryEntries() {
  const entries = [];
  for (const plugin of iterateBootstrapChannelPlugins()) {
    entries.push(...plugin.secrets?.secretTargetRegistryEntries ?? []);
  }
  return entries;
}

To:

function listChannelSecretTargetRegistryEntries() {
  return [];
}

After that:

  • openclaw agent --agent accounting --message "test" --json worked again
  • runtime skill injection checks were possible again

Still need to ship something?

×6

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

Back to top recommendations

TRENDING