fix: add codesign hook for esbuild on Darwin platforms #3491
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.
fix #3378
Signing esbuild binaries seem to fix the problem with failing tests on my machine (M1 Air/macOS 15.7):
Before:
Below is an analysis why this is happening.
Caveat: I am not sure if this fix is correct, or if this hiding symptoms for a deeper root cause, that this manual
codesign
step should not be necessary. But it works for me, now, and that makes me happy.For the curious, here are my notes while debugging this problem with the help of GPT-5 Codex -> https://gist.github.com/fry69/dca16c1164defd93a62adecaa0a2b2dd
Investigated the mac-only failures and found that macOS was killing the Vite/esbuild helper when a second dev server spun up; the crash logs showed
SIGKILL (Code Signature Invalid)
for the esbuild binary. These tests keep one long-lived server running while launching others, so the unsigned/adhoc esbuild binary in the npm cache got revalidated and terminated only on this platform, which is why CI (Linux) kept passing.actions taken
ensureEsbuildSigned()
in test_utils.ts to locatenpm:esbuild/bin/esbuild
, runcodesign --force --sign - …
once per process on Darwin, and surface clear guidance ifcodesign
isn’t available.launchDevServer
,spawnDevServer
, andbuildVite
so every Vite invocation now runs against a freshly re-signed binary.verification
deno fmt packages/plugin-vite/tests/test_utils.ts
deno test -A packages/plugin-vite/tests/dev_server_test.ts
(all 28 relevant cases now pass locally on macOS)notes & follow-ups
codesign
tool (installed with the Xcode Command Line Tools). If it’s missing, developers will get a direct error telling them to install it or sign the binary manually.