fix: avoid top-level await in bun-runner so hooks load on Node < 14.8#3061
Open
Kurama2d wants to merge 1 commit into
Open
fix: avoid top-level await in bun-runner so hooks load on Node < 14.8#3061Kurama2d wants to merge 1 commit into
Kurama2d wants to merge 1 commit into
Conversation
Contributor
Greptile SummaryThis PR removes top-level
Confidence Score: 5/5Safe to merge; the change is narrowly scoped to moving existing asynchronous startup logic out of module scope. The modified file preserves the existing control flow and behavior while improving compatibility with older Node ESM loaders.
What T-Rex did
Reviews (2): Last reviewed commit: "fix: avoid top-level await in bun-runner..." | Re-trigger Greptile |
bun-runner.js is an ES module that uses a top-level `await collectStdin()`. Top-level await is unsupported by the ESM loader of Node < 14.8, so on hosts where Claude Code invokes hooks with an older Node (e.g. the Node 12 shipped by Ubuntu 22.04 / many WSL setups) the module fails to load with "SyntaxError: Unexpected reserved word", breaking every claude-mem hook. Wrap the post-collectStdin body in an async IIFE so `await` is no longer at module scope. Same oldest-Node compatibility concern already handled in this file for optional chaining (see the `?.` note above isPluginDisabledInClaudeSettings). Repro: `node --check plugin/scripts/bun-runner.js` under Node 12 fails before this change and passes after.
950e33f to
7bb0672
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
plugin/scripts/bun-runner.jsis an ES module that uses a top-levelawait:Top-level await is unsupported by the ESM loader of Node < 14.8. On hosts where Claude Code invokes hooks with an older Node — e.g. the Node 12 that ships with Ubuntu 22.04 and many WSL setups — the module fails to load before running anything:
This breaks every claude-mem hook (e.g. the
Stophook surfaces it as a hook error) for those users.Fix
Wrap the body after
collectStdin()in an async IIFE soawaitis no longer at module scope. No behavior change on modern Node.This is the same oldest-Node compatibility concern the file already handles deliberately for optional chaining — see the
?.note aboveisPluginDisabledInClaudeSettings().Repro / verification
# Under Node 12: node --check plugin/scripts/bun-runner.jsSyntaxError: Unexpected reserved word