Skip to content

Build the backend on Node 22 on Railway - #8

Merged
coderback merged 1 commit into
mainfrom
fix-railway-node-22
Nov 5, 2026
Merged

coderback merged 1 commit into
mainfrom
fix-railway-node-22

Conversation

@coderback

@coderback coderback commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

The Railway deploy crashed on every start with Error: Node.js detected but native WebSocket not found, thrown while TokenVerifier creates the Supabase client.

Why

  • Railway builds packages/backend on its own, so it never sees the engines field in the root package.json and builds with Node 20.
  • supabase-js (realtime-js) needs Node 22's built-in WebSocket, and throws this error at startup when it's missing.
  • Local development and CI already run Node 22, so tests didn't catch it.

Change

Pin Node 22 inside packages/backend in three ways:

  • engines.node: ">=22.11.0" in package.json, matching the root;
  • nixpacks.toml with NIXPACKS_NODE_VERSION = "22";
  • .nvmrc.

Testing

  • I couldn't reproduce the crash here: downloading Node 20 wasn't permitted. Instead I read realtime-js's WebSocket check, which raises exactly this error when there's no global WebSocket. Node 22 has one.
  • Backend build passes, and 116 unit tests pass.

After merging, confirm the Railway build log uses Node 22 and that /health reports ok.

Railway builds packages/backend on its own, so it never saw the Node
22 requirement in the root package.json and used Node 20. supabase-js
needs Node 22's built-in WebSocket and crashed at startup without it.
Pin Node 22 in the backend's package.json, a nixpacks.toml and .nvmrc.
@vercel

vercel Bot commented Nov 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
grit-demo Ready Ready Preview Nov 5, 2026 12:36am UTC

@coderback
coderback merged commit 44baaae into main Nov 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant