feat: warn at build time when the server build targets a worker runtime (ssr.target webworker) - #373
Merged
Merged
Conversation
The generated server code (the start-mode handler and the server-function handler module) imports `@solidjs/web/storage`, the one Solid module that needs `node:async_hooks`. A build with `ssr.target: 'webworker'` (what Shopify Oxygen's Vite plugin sets) only failed at deploy with a bare `No such module "node:async_hooks"` (solidjs/solid#3597). Name the requirement and both fixes at build time instead: a compatibility_date of 2026-08-04 or later, or the nodejs_compat flag. Detected in configResolved (build + start or serverFunctions + webworker target), emitted from the ssr environment's buildStart so it lands exactly once per server build — the default builder resolves the config once per environment on top of its own pass, so a configResolved warning printed three times. Never in dev, where the ssr environment runs in Node. Co-authored-by: Claude via Cursor <noreply@cursor.com>
🦋 Changeset detectedLatest commit: de42b22 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Emit a build-time warning when the server build targets a worker runtime (
ssr.target: 'webworker') and the plugin generates server code — SSR or client start mode, orserverFunctionson its own.Why
Follow-up promised in solidjs/solid#3597 (the maintainer's comment). The generated server code — the start-mode handler (
src/ssr/index.ts) and the server-function handler module (src/server-functions/index.ts) — imports@solidjs/web/storage, the one Solid module that needsnode:async_hooks(AsyncLocalStoragekeeps the request event live acrossawaits; there is no sync-scope fallback). On a worker runtime without Node compat that failed at deploy with a bareNo such module "node:async_hooks". Shopify Oxygen's Vite plugin (@shopify/mini-oxygen) setsssr.target: 'webworker', so the target is the signal; the reporter verified Oxygen works with acompatibility_date≥ 2026-08-04 and asked that the warning mention both that route and thenodejs_compatflag.How
configResolved(src/index.ts):command === 'build'and (startorserverFunctionsset) and resolvedconfig.ssr.target === 'webworker'— the same property Vite itself reads for thessrenvironment.buildStartwhenthis.environment.name === 'ssr', throughconfig.logger.warnlike the plugin's other config-level warnings. This is what makes it fire exactly once per build: Vite's default builder (sharedConfigBuild: false) resolves the config once for the builder and once per environment, so aconfigResolved-time warning printed three times pervite build(verified before moving it). It does not fire for the client build, and never in dev (the ssr environment runs in Node there). Works for a fullvite build(builder),vite build --ssr, and host orchestrators that build thessrenvironment themselves.ssr: trueconfig (no generated server code) stays silent; whether the user's own server imports@solidjs/web/storageis theirs to know.Warning text
Tests
examples/start-ssr/test/webworker-warning.mjs(added to the example'stestscript, aftercomponents-warning.mjs). Real in-process builds, no browser:buildApp(), client + ssr) + text assertions: namesssr.target = "webworker",node:async_hooks/AsyncLocalStorage, thecompatibility_dateroute (2026-08-04), thenodejs_compatflag route, Shopify Oxygen, and links [2.0 rc.9] Start mode server handler requires node:async_hooks, fails on Workers runtimes without Node compat solid#3597Also ran locally:
pnpm build, the fullexamples/start-ssrsuite (run.mjs600/600,http-bridge.mjs,components-warning.mjs), prettier on the touched files.Public API changes
None. No new option or config surface; the condition is the resolved
ssr.target.Notes for review
serverFunctionswithoutstart, because that path's handler module carries the same@solidjs/web/storageimport and fails identically on a worker without Node compat. Easy to narrow tostartonly if preferred.patch, matching the vast majority of changesets onnext.Refs solidjs/solid#3597
— Claude via Cursor