Skip to content

Commit 7bb0672

Browse files
committed
fix: avoid top-level await in bun-runner so hooks load on Node < 14.8
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.
1 parent 3fe0725 commit 7bb0672

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

plugin/scripts/bun-runner.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ function collectStdin() {
125125
});
126126
}
127127

128+
// Wrapped in an async IIFE: top-level `await` is unsupported in the ESM loader
129+
// of Node < 14.8, which some Claude Code installs invoke hooks with (e.g. the
130+
// Node 12 shipped by Ubuntu 22.04 / many WSL setups). There it throws
131+
// "SyntaxError: Unexpected reserved word" at module load, breaking the hook.
132+
// Same oldest-Node compatibility reason as the optional-chaining note above.
133+
(async () => {
128134
const stdinData = await collectStdin();
129135

130136
const spawnOptions = {
@@ -236,3 +242,4 @@ child.on('close', (code, signal) => {
236242
}
237243
process.exit(code || 0);
238244
});
245+
})();

0 commit comments

Comments
 (0)