fix(server): self-heal a non-executable bundled resource-monitor binary - #7801
fix(server): self-heal a non-executable bundled resource-monitor binary#7801Exotic209093 wants to merge 1 commit into
Conversation
npm only preserves the executable bit for files listed in package.json's bin field, so the Rust resource-monitor sidecar we bundle under dist/resource-monitor/<platform>-<arch>/ always lands on disk as 0644 after `npm pack`/`publish`, regardless of the chmod +x the release workflow already runs beforehand. ResourceMonitorBinary.resolve then failed closed and native process telemetry never started. Bundled candidates are paths we ship ourselves, so repair the exec bit at resolve time instead of staying permanently unavailable. A user-supplied override path (env var / config) is left untouched and still fails closed, since auto-chmod'ing an arbitrary path we didn't build isn't safe. Fixes pingdotgg#7736
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a straightforward bug fix that self-heals bundled binaries losing executable permissions during npm packaging. The change is well-scoped, includes proper security considerations (only modifying owned paths, not user-supplied ones), and has test coverage. You can add or adjust custom eligibility rules. Learn more. |
Summary
Fixes #7736.
t3 serveon Linux/macOS logs `Resource monitor binary ... is not executable` and native process telemetry never starts. The published npm tarball ships `dist/resource-monitor/-/t3-resource-monitor` as `0644`.The release workflow already runs `chmod +x` on these sidecars before publish (added 2026-07-29), so the CI-side fix in the issue's first suggestion is already in place — yet the published tarball still shows `0644`. That's because npm only preserves the executable bit for files listed in `package.json`'s `bin` field; any other file, including ours, gets re-packed without it regardless of its on-disk mode at pack time (the same class of issue as `node-pty`'s `spawn-helper`, referenced in the issue as #4924).
Fix
Since CI-side chmod can't survive npm's packing, this implements the issue's second suggested fix: `ResourceMonitorBinary.resolve` now repairs the executable bit at resolve time for binaries T3 bundles itself, instead of failing closed. A user-supplied override path (`T3CODE_RESOURCE_MONITOR_PATH` / config) is left untouched and still fails closed on a non-executable file — auto-chmod'ing an arbitrary path we didn't build isn't safe.
Test plan
apps/server/src/resourceTelemetry/ResourceMonitorBinary.test.tscoverage that writes a bundled sidecar at 0644 and confirmsresolverepairs it and returns the path.vp test run apps/server/src/resourceTelemetry— 50 passed (run under WSL/Linux; two pre-existing POSIX-mode tests in this suite don't reflect real chmod semantics on native Windows and were unaffected by this change).vp run --filter t3 typecheck— clean.vp linton changed files — clean.Note
Medium Risk
Adds a runtime chmod of bundled binaries on disk. Scope is limited to owned sidecar paths; overrides remain fail-closed, but this still mutates file modes at resolve time.
Overview
Fixes resource-monitor telemetry on Linux/macOS after npm packs bundled sidecars as
0644.ResourceMonitorBinary.resolvenowchmods owned bundled binaries that lack the execute bit, then returns the path.User-supplied override paths (
T3CODE_RESOURCE_MONITOR_PATH/ config) stay fail-closed so we never chmod an arbitrary file. Adds a test that writes a bundled sidecar at0644and asserts it is repaired.Reviewed by Cursor Bugbot for commit 95949ed. Configure here.
Note
Fix
resourceMonitorBinary.maketo self-heal non-executable bundled binarySome npm package layouts strip the execute bit from the bundled resource-monitor binary, causing resolution to fail on Linux. When a bundled (owned) candidate exists but lacks any execute bit (
mode & 0o111 == 0), the factory now chmods the file to add execute bits and succeeds, instead of returningResourceMonitorBinaryNotExecutable.{ path, owned }, marking override candidates asowned: falseand bundled candidates asowned: trueResourceMonitorBinaryNotExecutable; only bundled binaries are auto-repairedresolverepairs the mode and returns the pathMacroscope summarized 95949ed.