Skip to content

fix(sidecar/prepare-node): prefer process.execPath; reject shims#11

Merged
mrdulasolutions merged 1 commit into
mainfrom
claude/preparenode-use-execpath
May 12, 2026
Merged

fix(sidecar/prepare-node): prefer process.execPath; reject shims#11
mrdulasolutions merged 1 commit into
mainfrom
claude/preparenode-use-execpath

Conversation

@mrdulasolutions
Copy link
Copy Markdown
Owner

Summary

v0.1.8's release tarball came out to 9.4 MB instead of the expected ~70 MB. Looking at the contents:

File Size Expected
`aos-mail` (Rust) 8.4 MB
`aos-mail-sidecar` (bundled JS) 35 MB
`better_sqlite3.node` 1.9 MB
`aos-mail-node` 86 KB ~60-80 MB

The bundled Node binary is an 86 KB stub. Running the sidecar would crash immediately when the bash stub tries to `exec` it.

Root cause

`sidecar/scripts/prepare-node-binary.mjs`'s `findSystemNode()` picks the first existing path from a static list: `/opt/homebrew/bin/node` → `/usr/local/bin/node` → `/opt/local/bin/node` → `command -v node`. On macos-latest GitHub runners, `/opt/homebrew/bin/node` exists but is a small launcher/shim, not the real binary. `existsSync()` returned true, `copyFileSync()` happily copied 86 KB.

Fix

  1. Prefer `process.execPath` — the node interpreter actually running this script. By definition a real Node binary in the version the build expects. In CI with `setup-node@v4`, this resolves to `$RUNNER_TOOL_CACHE/node///bin/node` — the actual ~80 MB binary.
  2. Reject shims: skip any candidate smaller than 10 MB with a warning. Real Node binaries are ≥60 MB; anything smaller is a wrapper that would produce a non-functional bundle.

Verified locally

```
source: /usr/local/bin/node
target arch: arm64 (rustc triple aarch64-apple-darwin)
prepared bundled node -> .../aos-mail-node-aarch64-apple-darwin (112.7 MB)
```

After merge

I'll move the v0.1.8 tag again. This is the last (we hope) issue blocking a working release.

🤖 Generated with Claude Code

v0.1.8's release tarball came out to 9.4 MB instead of the expected
~70 MB because prepare-node-binary.mjs bundled an 86 KB stub instead
of the real Node binary. The script picked /opt/homebrew/bin/node
on the macos-latest runner, which exists but appears to be a small
launcher/shim rather than the full binary. Running the bundled
sidecar would crash at startup with garbage from that file.

Two complementary fixes:

1. Prefer `process.execPath` — the node interpreter actually running
   this script. It's by definition a real Node binary in the version
   the build expects. Especially reliable in CI where setup-node@v4
   places node in a stable cache path and execPath resolves there.

2. Reject any candidate smaller than 10 MB with a warning. Real
   Node binaries are at least ~60 MB on macOS; anything in the
   hundreds of KB range is a shim and would produce a non-functional
   bundled node. Warn and skip rather than silently shipping garbage.

Verified locally: now picks /usr/local/bin/node (process.execPath)
and produces a 112.7 MB bundled node. The build would have shipped
an 86 KB stub before this patch.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@mrdulasolutions mrdulasolutions merged commit 3015659 into main May 12, 2026
2 of 3 checks passed
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