build timing out after adding new variables
slaterprycegeorge-png
PROOP

a month ago

I'm getting a build timeout after adding new variables. THinking this might be something having to do with not doing a full redeploy I pushed a new deploy from github.

I'm now on the third attempt and it's still building (11 minutes). It'll fail after about 45 minutes like the others I'm sure.

Context, this is a pretty small API. Last build 20 hours ago went fine, biggest difference is I added environment variables. Usually takes 2 minutes.

current deployment id is 0eb700d2-6016-4a49-b8f5-0992146fab16

the logs aren't really telling me anything.

any help so I can figure out how to debug this or fix it?

2 Replies

slaterprycegeorge-png
PROOP

a month ago

RESOLVED - Railway Build Timeout / "context canceled" Error

Sharing our solution in case it helps others:

The Problem:
Our Node.js/TypeScript backend was timing out during Railway builds with a "context canceled" error. Root cause was heavy devDependencies (jsdom ~40MB, vitest, fast-check) consuming too much memory/time.

What We Tried (and failed):

Custom build command (npm install && npm run build) in Railway settings - didn't help
Created nixpacks.toml with build/install/prune phases - Railway wasn't reading it
The Fix:
Turns out Railway now uses Railpack instead of Nixpacks as the default builder. The nixpacks.toml config is deprecated.

Created a railpack.json in the project root:

{  "$schema": "https://schema.railpack.com",  "packages": {    "node": "22"  },  "deploy": {    "startCommand": "node dist/server.js"  }}
Important gotcha for Windows/PowerShell users:
PowerShell's Out-File -Encoding utf8 adds a BOM (Byte Order Mark) character to files. Railpack's JSON parser chokes on this with the error:

invalid character '\ufeff' at start of value
To write UTF-8 without BOM in PowerShell:

[System.IO.File]::WriteAllText("$PWD\railpack.json", $content, [System.Text.UTF8Encoding]::new($false))
Key Takeaways:

Railway migrated from Nixpacks → Railpack
Railpack auto-detects npm, runs npm run build, and prunes devDependencies automatically
Only need minimal config (node version + start command)
Watch out for BOM encoding if creating config files on Windows
Hope this helps someone else!


yuyulbm
HOBBY

a month ago

I think this is what’s happening to mine too


Loading...