Skip to content

EAS builder pins Node 20.19.4, which caps @supabase/supabase-js at 2.86 (realtime-js needs a native WebSocket) #512

Closed

Description

@thinkclay

What happened

The v1.16.0 iOS build (8af7b052, build 11201) failed at the EAGER_BUNDLE phase:

Error: Node.js detected but native WebSocket not found.
Suggested solution: Ensure you are running Node.js 22+ or provide a WebSocket
implementation via the transport option.
    at getWebSocketConstructor (@supabase/realtime-js/dist/main/lib/websocket-factory.js:86)
    at new RealtimeClient
    at SupabaseClient._initRealtimeClient
    at createClient
    at packages/scf-core/utils/supabase/client.ts:52
    …
    at getBuildTimeServerManifestAsync (@expo/router-server/build/static/getServerManifest.js:23)

Why

@supabase/supabase-js 2.110's bundled realtime-js requires a native WebSocket global when it detects Node. Expo Router calls createClient under Node while generating the build-time route manifest (packages/scf-core/utils/supabase/client.ts is reached from useUser → useProtectedRoute → app/(admin)/_layout.tsx).

apps/scaffald/eas.json pins the production profile to "node": "20.19.4". Node 20 has no global WebSocket (it landed unflagged in Node 22). So the manifest generation throws and the bundle phase dies.

It passes locally, which is the trap: local Node is 22.x, where WebSocket is a global. Pods, typecheck, unit tests, and the web export were all green — the web bundle never exercises this path the same way.

Reproduced deterministically without needing a Node 20 install:

delete globalThis.WebSocket
const { createClient } = await import('@supabase/supabase-js')
createClient('https://example.supabase.co', 'anon-key')
supabase-js result
2.110.9 throws Node.js detected but native WebSocket not found.
2.86.2 OK

Immediate action

Reverted @supabase/supabase-js to ~2.86.0 in both the catalog and the pnpm override, with a comment on the catalog entry pointing here. Dependabot will try to bump it again — that is what this issue is for.

To actually unblock the upgrade, pick one

  1. Raise the EAS builder Node to 22.x in eas.json (production, and the other profiles for consistency). Cleanest — Node 22 is current LTS — but it changes the build toolchain and deserves its own build to validate.
  2. Pass a transport to createClient in packages/scf-core/utils/supabase/client.ts so realtime never reaches for a global. Narrower, and makes the client independent of the runtime's WebSocket support.
  3. Don't construct the client at module scope on a path expo-router loads at build time — lazy-init it. Arguably the most robust, since it stops build-time manifest generation from touching runtime clients at all.

Option 2 or 3 is probably right regardless; 1 alone leaves the same landmine for the next runtime that lacks WebSocket.

Also worth fixing: these logs are readable

The EAS logFiles URL is brotli-encoded NDJSON, not the opaque blob it appears to be (file reports data, and gzip/zstd/xz all fail). brotli -dc < log.bin yields one JSON object per line with a phase and msg, which is how the stack trace above was recovered without the dashboard. Worth writing down — the prevailing assumption has been that EAS build errors can only be read in the browser.

Activity

  1. thinkclay commented on Jul 30, 2026

    @thinkclay
    ContributorAuthor

    Both halves landed in #516 and proven against supabase-js 2.110.9 with a local export:embed --eager harness (eager client fails with the exact WebSocket error, lazy client passes; same deps, same stripped runtime). Key discovery for future debugging: plain expo export --platform ios does NOT run the failing 'Exporting server' step — export:embed --eager is what EAS runs. The ~2.86 pin now waits only on runtime validation of the 2.86→2.110 auth/realtime surface. A no-submit production-profile build is validating the Node 22 toolchain on the real builder.

  2. thinkclay commented on Jul 30, 2026

    @thinkclay
    ContributorAuthor

    Node 22 toolchain confirmed on the real builder: production-profile validation build 74e0b6bb (v1.16.1 / 11203, commit 5513577, no submit) FINISHED in 7m11s — through EAGER_BUNDLE, the phase that killed 11201. The builder-side half of this issue is fully validated end to end. Remaining follow-up lives on the catalog note: runtime-validate the supabase-js 2.86→2.110 auth/realtime surface in its own PR, which is now safe to attempt.

  3. added 2 commits that reference this issue on Aug 27, 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

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions