Skip to content

fix: preserve cyclic tool exports during chunk loading - #12

Open
cracer4869 wants to merge 1 commit into
CometixSpace:masterfrom
cracer4869:fix/defer-cyclic-tool-exports
Open

fix: preserve cyclic tool exports during chunk loading#12
cracer4869 wants to merge 1 commit into
CometixSpace:masterfrom
cracer4869:fix/defer-cyclic-tool-exports

Conversation

@cracer4869

Copy link
Copy Markdown

Summary

  • keep cyclic Tool/TOOLS exports live when the Node require() shim encounters ERR_REQUIRE_CYCLE_MODULE
  • avoid caching a partially initialized tool export as undefined, which later causes Cannot read properties of undefined (reading 'name')
  • add a Node regression fixture for deferred cyclic exports and preserve the existing primitive-export behavior

Root cause

Starting with Claude Code 2.1.250, split ESM chunks use synchronous require() edges that can point back through the static import graph. The compatibility shim correctly returned undefined for cyclic primitive exports, but the same behavior was applied to object-valued tool exports. In 2.1.259, ProposeSkillsTool was captured this way and unconditionally added to the built-in tool list; tool discovery then read .name from the stale undefined value.

Verification

  • npm test
  • node --check scripts/esm-chunk-patch.mjs
  • git diff --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant