Repository navigation
fix(scf-core): lazy-init the Supabase client; run the EAS builder on Node 22 - #516
Merged
Merged
Conversation
…Node 22 Two halves of #512, each sufficient alone, both taken: 1. packages/scf-core/utils/supabase/client.ts no longer calls createClient at module scope. expo-router evaluates route modules UNDER NODE at build time to generate the server manifest (export:embed → exportStandaloneServerAsync → getBuildTimeServerManifestAsync), and this module is reachable from route layouts via useProtectedRoute → useUser. Construction now happens on first property access behind a Proxy, so importing the module is side-effect-free and every existing `supabase.…` call site works unchanged. 2. apps/scaffald/eas.json production builder moves node 20.19.4 → 22.20.0 (matching this machine, so local verification runs on what production builds on) and root package.json declares engines.node >=22. Node 22 has the native WebSocket global that newer @supabase/realtime-js demands. Verified with a harness that reproduces EAS's EAGER_BUNDLE locally — plain `expo export --platform ios` does NOT exercise the failing path (it skips the "Exporting server" step), which is why the v1.16.0 breakage passed local verification. The real invocation is `expo export:embed --eager`: NODE_OPTIONS=--require strip-websocket.cjs # delete globalThis.WebSocket, expo export:embed --eager --platform ios --dev false # = Node 20 behavior eager client + supabase-js 2.110.9 → exit 1, "Node.js detected but native WebSocket not found" (the EAS error) lazy client + supabase-js 2.110.9 → exit 0, bundle written Same command, same deps, same stripped runtime; only the lazy-init differs. supabase-js itself stays pinned at ~2.86: the build-time blocker is gone, but the 2.86→2.110 runtime surface (auth/realtime) deserves its own PR. The catalog note now says exactly that. APP_IOS_BUILD_NUMBER moves to 11203 so a validation build cannot collide with the shipped 11202 (#513 tracks making release.sh do this). Refs #512, refs #513 Co-Authored-By: Claude Fable 5 <[email protected]>
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.
Closes #512 (both remediation halves — each sufficient alone, both taken).
What
packages/scf-core/utils/supabase/client.tsno longer callscreateClientat module scope. expo-router evaluates route modules under Node at build time to generate the server manifest, and this module is reachable from route layouts (useProtectedRoute → useUser → client.ts). Construction now happens on first property access behind a Proxy — importing the module is side-effect-free, and every existingsupabase.…call site works unchanged.eas.jsonproduction profile:node 20.19.4 → 22.20.0(matching this machine, so local verification runs on what production builds on), plus rootengines.node >=22.The harness — and why v1.16.0 passed local verification while breaking on EAS
Plain
expo export --platform iosdoes not exercise the failing path: it skips the "Exporting server" step entirely. The EASEAGER_BUNDLEphase runsexpo export:embed --eager, which additionally bundles and evaluatesgetServerManifestunder Node. That's the gap that let the v1.16.0 regression through.Reproduction (Node 20 simulated via
NODE_OPTIONS=--requirepreload that deletesglobalThis.WebSocket):export:embed --eagerresultNode.js detected but native WebSocket not found(the exact EAS error) ✅Same command, same deps, same stripped runtime; only the lazy-init differs. Causal.
Deliberately not in this PR
@supabase/supabase-jsstays pinned at~2.86. The build-time blocker is gone (proven above against 2.110.9), but the 2.86→2.110 runtime surface (auth/realtime behavior in the app) deserves its own PR with its own validation. The catalog note now says exactly that.APP_IOS_BUILD_NUMBER→ 11203 so a Node-22 validation build can't collide with the shipped 11202 (#513 tracks automating this in release.sh).Fresh (cache-skipped) scf-core typecheck, unit tests, and prepush all pass. Next step after merge: a production-profile EAS build without submit to validate the Node 22 toolchain on the real builder.
🤖 Generated with Claude Code