Skip to content

fix(rivet): type a 404 without x-rivet-ray-id as EngineNotReady - #1360

Open
sam-goodwin wants to merge 1 commit into
mainfrom
fix/rivet-engine-not-ready
Open

sam-goodwin wants to merge 1 commit into
mainfrom
fix/rivet-engine-not-ready

Conversation

@sam-goodwin

Copy link
Copy Markdown
Member

A Rivet engine behind a platform's router (Railway) gets the platform's own 404 page while it starts or restarts. The SDK typed that as the generic NotFound, so callers couldn't tell a starting engine from a missing pool. It's now EngineNotReady.

yield* Pools.deletePool({ pool, namespace }).pipe(
  Effect.retry({
    while: (error) => error._tag === "EngineNotReady",
    schedule: Schedule.spaced("5 seconds"),
    times: 10,
  }),
);

What Railway sends while the engine starts:

HTTP/2 404
x-railway-fallback: true

{"status":"error","code":404,"message":"Application not found","request_id":"…"}

The engine stamps x-rivet-ray-id on every response, including its own 404 for an unknown path, so a 404 without it did not come from the engine. That's a classifyError rule rather than a patch: a matcher can't match a missing header, and it holds for every operation.

This supersedes #1326, which read the same response as ServiceUnavailable. A tag of its own lets callers bound this wait separately: the same page answers for a host that serves no engine at all, so it shouldn't get a down engine's full startup budget.

Used by alchemy-run/alchemy#3466.

@github-actions

Copy link
Copy Markdown
Contributor

Benchmarks: PR aa1470ef6 vs main 294d116ba

  • ⚪ Bundle size 54.7 KB: ±0.0% (±0 B), same as main
  • ⚪ Runtime speed 3.4 µs: +31.7% (+0.8 µs), same as main
  • ⚪ Runtime memory 795.4 KB: ±0.0% (±0 B), same as main
  • ⚪ Objects at import 1,084: ±0.0% (±0), same as main
  • ⚪ Whole-SDK memory aws 39.7 MB (unchanged), cloudflare 8.27 MB (unchanged), gcp 24.8 MB (unchanged)
  • ⚪ Repo size 543.9 MB tracked in 9,896 files, same as main (+1.8 KB). .generated-specs/ 0 B, src/services/ 512.0 MB, everything else 31.9 MB.

sdk-memory

bundle-programs

memory-programs

bundle memory
speed objects

Numbers
Metric Change vs main Programs
Bundle (gzip) no change 17
Import heap no change 6
Objects at import no change 6
Added latency (p50) ¹ no change 6
Import time ¹ no change 6
First call ¹ no change 6
Program Call Bundle (gzip) Import heap Objects at import Added latency (p50) Import time First call
aws s3.listBuckets 79.4 KB — — — — —
aws~awsJson1_0 dynamodb.listTables 71.7 KB — — — — —
aws~awsJson1_1 kms.listKeys 70.9 KB — — — — —
aws~awsQuery sts.getCallerIdentity 72.3 KB — — — — —
aws~ec2Query ec2.describeRegions 72.4 KB — — — — —
aws~restJson1 lambda.listFunctions 73.1 KB — — — — —
azure resources.ListTenants 57.0 KB — — — — —
cloudflare workers.listScripts 69.3 KB — — — — —
cloudflare~CloudflareProtocol ips.listIps 49.9 KB — — — — —
fly-io machines.getRegions 50.9 KB 776.7 KB 1,088 4.1 µs 8.0 ms 3.1 ms
fly-io~FlyApiProtocol mpg.listUsers 50.6 KB 651.2 KB 982 2.9 µs 7.4 ms 3.0 ms
fly-io~SpritesProtocol sprites.createOrganizationToken 51.3 KB 706.1 KB 1,024 7.1 µs 7.5 ms 3.2 ms
gcp storage_v1.listBuckets 51.8 KB — — — — —
github gists.list 53.4 KB 656.5 KB 954 3.4 µs 7.1 ms 3.2 ms
neon neon.listProjects 52.1 KB 837.8 KB 1,084 2.1 µs 7.6 ms 3.3 ms
resend resend.listLogs 51.9 KB 859.3 KB 1,144 2.2 µs 8.0 ms 3.0 ms
stripe stripe.GetFiles 50.1 KB — — — — —

PR aa1470ef6 against main 294d116ba (main's cached run from 2026-11-21 04:12 UTC). 17 programs, measured in 21 s on 8 vCPU.

Package Tarball Unpacked Files
core 331.2 KB 1.3 MB 229
fly-io 250.2 KB 1.6 MB 71
github 2.1 MB 19.6 MB 338
neon 221.4 KB 1.2 MB 47
resend 173.2 KB 1.2 MB 57
rivet 35.1 KB (+3.5%) 220.0 KB (+1.9%) 74
Tracked files Size Change vs main Files
services 512.0 MB ±0 B 3,024
in-tree-specs 98.3 KB ±0 B 4
patches 10.1 MB ±0 B 4,189
handwritten 9.6 MB +1.8 KB 1,957
benches 9.6 MB ±0 B 207
other 2.6 MB ±0 B 515
Total 543.9 MB +1.8 KB 9,896

What a checkout or worktree writes to disk, from git ls-tree (benches/repo-size/tree.ts). The dashboard's Repo size page has the full picture.

Effect alone: effect-minimal bundle 8.9 KB gzip, hand-written effect-http call 48.6 KB gzip; effect import 70.8 ms and 12.8 MB heap; bare mocked HTTP roundtrip 10.9 µs p50.

Bundled (from src/): resend, neon, github, fly-io, aws, cloudflare, gcp, azure, stripe, rivet. Built and probed (from lib/): resend, neon, github, fly-io, rivet. Changed in this PR: rivet. No target in targets.json: rivet.

Job time: bundle 6.5 s, build: tsrs 0.2 s, build: bundle-lib 2.1 s, build: strip-lib-docs 0.1 s, build 2.4 s, size 0.9 s, runtime 11.7 s, providers 0.0 s.

¹ Timings run on a different runner than main's, so 🟡 marks a large move that may still be noise. Sizes, heap and object counts are stable. Offline: every call hits a canned in-memory response. Full suite: node benches/sdks/run.ts. Job log

@alchemy-version-bot

Copy link
Copy Markdown
Contributor

Install the packages built from this commit:

@distilled.cloud (2)
pnpm install https://pkg.distilled.cloud/@distilled.cloud/core/pr:1360:aa1470e
pnpm install https://pkg.distilled.cloud/@distilled.cloud/rivet/pr:1360:aa1470e

Published Nov 21, 2026, 9:37 AM UTC. Expires Nov 28, 2026, 9:37 AM UTC, extended while this pull request is open.

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