Skip to content

chore(deps): lift the @swc/core pin once SWC builds on Workers Builds #405

Closed

Description

@Ardnived

Summary

The Ladle playground (sahajatlas-design) builds only because @swc/core is held at 1.16.2 by a pnpm.overrides entry (#401). Since 1.16.12, SWC unpacks its native addon into a cache directory and refuses any directory whose ancestors another user can write without a sticky bit. On the Workers build image, since 2026-11-13, that rules out both ~/.cache and /tmp, so every playground build failed with ERR_SWC_NATIVE_CACHE before Ladle ran. 1.16.22 still fails. The pin leaves us on an aging compiler that receives no fixes, so lift it once an upstream release or a change to the build image makes a newer SWC load there.

Approach

  1. Check whether a newer @swc/core loads its addon on Workers Builds. Look for one of: an upstream release that falls back when the cache directory is refused, an environment variable that points the cache somewhere the image allows, or a change to the build image's directory permissions. SWC_NATIVE_BINDING_CACHE=/tmp/... did not work, because /tmp is refused too. Testing on macOS can't reproduce the failure, since /private/tmp there has the sticky bit.
  2. Drop "@swc/core": "1.16.2" from pnpm.overrides in package.json, and run pnpm install to refresh pnpm-lock.yaml.
  3. Remove the ⚠ @swc/core paragraph from the sahajatlas-design bullet in docs/rules/deployment.md.

Acceptance criteria

  • package.json has no @swc/core override, and the lockfile resolves a release newer than 1.16.11.
  • The sahajatlas-design Workers build passes on the PR's preview and again on main after merge.
  • docs/rules/deployment.md no longer describes the pin.

Verification checklist

  • pnpm why @swc/core reports a version above 1.16.11.
  • The Workers Builds: sahajatlas-design check run on the PR is green, and its log shows no ERR_SWC_NATIVE_CACHE.
  • pnpm ladle:build succeeds locally.

Notes

The failing build logs were 8712be11 (on 1.16.x with a /tmp cache) and 1413ebd6 (on 1.16.22). The first green build after the pin was 307a9844.

Measured 2026-11-13 against @swc/core 1.16.22, by unpacking the addon and reproducing the refusal:

  • 1.16.22 (2026-11-05) is the newest release, and the newest nightly. Nothing upstream has moved, so step 1's first route is closed today.
  • binding.js is byte-identical between 1.16.2 and 1.16.22. The refusal comes from the addon itself (crates/swc_native_addon), not the JS loader. Each Linux platform package ships one file: a 10.7 MB carrier that materialises a 31 MB addon at first load.
  • Load order, from the addon's own strings: self-replacement at the carrier path → SWC_NATIVE_BINDING_CACHE → $XDG_CACHE_HOME/$HOME/.cache/swc-native-<uid>/v1 → a temporary addon in TMPDIR.
  • The cache root must be absolute, a real directory owned by the current user with mode 0700, not on a noexec mount, and must have no parent "writable by another user without trusted sticky protection".
  • Reproduced as an unprivileged user: a 0700 root under a root-owned 0777 non-sticky parent, with TMPDIR non-sticky so the last fallback could not mask it, fails with custom cache failed: validate cache root <p>: cache root has a parent writable by another user without trusted sticky protection. Two variations of that same run load: a cache root whose chain is owned end to end by the running user, and the failing root plus SWC_NATIVE_BINDING_CACHE_SKIP_SECURITY_CHECK=1 ("skipping native cache root security check by explicit environment opt-out"). Integrity checking is a separate stage and stays on either way.
  • Only the playground is exposed. @swc/core has exactly one dependent in the lockfile, @vitejs/[email protected], imported only by @ladle/[email protected]. vite.config.ts compiles the app with @vitejs/plugin-react (Babel), so no sahajatlas-web deploy rides on this.
  • docs(deployment): name the real gate on lifting the @swc/core pin #406 rewrites the docs/rules/deployment.md sentence that told a reader to wait for upstream.

Open questions

How should the pin be lifted, now that upstream is not the gate? Criterion 2 cannot be met by waiting for a release. Three routes:

  • A — point the cache inside the build workspace. Set SWC_NATIVE_BINDING_CACHE to an absolute path in the checkout, from the Ladle script. No security opt-out, and measured to work when the chain is owned by the build user. ⚠ It may not hold here: ~/.cache being refused means an ancestor of $HOME is other-owned and writable, and a workspace under $HOME shares that ancestor.
  • B — opt out of that one check. SWC_NATIVE_BINDING_CACHE_SKIP_SECURITY_CHECK=1 beside a workspace-local 0700 root, set only for the playground build. Measured to work whatever the image's permissions are. It trades SWC's ancestry check for a compiler upgrade on a build that ships no app code; the payload integrity check still runs. Your call, not ours.
  • C — keep the pin. Free today. The compiler ages and receives no fixes, which is this ticket's reason to exist.

A and B both turn on one fact nobody has read: the build user, and the owner and mode of /, $HOME and the checkout on Workers Builds. A stat line in the playground build command answers it on one preview build and makes the choice between A and B factual.

Recommendation: add that stat line, read it off one build, then take A if the chain is clean and B if it is not.

Activity

  1. added theissue type on Nov 13, 2026
  2. Ardnived commented on Nov 13, 2026

    @Ardnived
    ContributorAuthor

    @sydevs-bot implement

  3. added
    bot:working
    on Nov 13, 2026
  4. sydevs-bot commented on Nov 13, 2026

    @sydevs-bot
    Contributor

    🤖 no session running
    approved by Ardnived

    recent dispatches
    • 22:18Z implement · attempt 1 · session · done
    • 22:18Z implement · attempt 1 · session

    Written by the sydevs dispatcher. Sessions never edit this comment.

  5. moved this from Awaiting to Working in SYDevelopers Technical Roadmapon Nov 13, 2026
  6. sydevs-bot commented on Nov 13, 2026

    @sydevs-bot
    Contributor

    I did not lift the pin. 1.16.22 (2026-11-05) is the newest release and still fails, so this ticket's trigger has not fired.

    Upstream was never the only route. The refusal comes from the addon's own cache-root check, not the JS loader — binding.js is byte-identical across 1.16.2 and 1.16.22. I reproduced it as an unprivileged user and measured two ways past it: a cache root whose parent chain the build user owns, and SWC_NATIVE_BINDING_CACHE_SKIP_SECURITY_CHECK=1. The error text and the load order are now in Notes.

    Both routes turn on one unread fact: the owner and mode of /, $HOME and the checkout on Workers Builds. Open questions lays out A, B and C with a recommendation. B is a security opt-out, so that call is yours.

    #406 corrects the deployment rule that sent a reader to wait for upstream. Only the playground loads SWC, so no app deploy rides on this.

    🤖 Written by the sydevs autonomous loop — see what this is


    Generated by Claude Code

  7. removed
    bot:working
    on Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    Low

    Hold Until

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions