Skip to content

fix(wallet): stop the federation route pulling a client module into the server - #1331

Merged
Miracle656 merged 1 commit into
mainfrom
fix/federation-server-build
Nov 8, 2026
Merged

Miracle656 merged 1 commit into
mainfrom
fix/federation-server-build

Conversation

@Miracle656

Copy link
Copy Markdown
Owner

#1330 broke the wallet build on main.

lib/federationServer.ts imported getNetwork from lib/network.ts, which
imports @veil/sdk, whose entry exports a React hook. That made the route
handler a React Server Component importing useEffect:

You're importing a module that depends on `useEffect` into a React Server
Component module.
./lib/federationServer.ts
./app/api/federation/route.ts

npx tsc --noEmit passes throughout — only next build catches it, which is
how it got through review and the typecheck job.

Production was never broken. The failed build simply never deployed, so
app.useveilapp.xyz kept serving the previous one — which is also why
/api/federation was still answering with Next's HTML 404 after #1330 merged.
The #1329 security fix had already deployed and is live (/api/names/available
returns 503).

The fix

Reads the two network fields this module needs from the environment, mirroring
NETWORKS in lib/network.ts, with one deliberate difference:
resolveMainnetRpcUrl() there returns the same-origin proxy /api/rpc/mainnet
and an empty string when there is no window — which is always, on the server.
So mainnet reads MAINNET_RPC_URL, the upstream the proxy itself uses, rather
than asking the server to proxy to itself.

An unset RPC URL now returns null explicitly rather than falling through the
catch-all, so "no RPC configured" and "RPC said no" reach the caller the same
way — a 404.

Verification

  • npm run build — compiles successfully (the step that failed)
  • npx tsc --noEmit — clean
  • 32 federation tests still pass

https://claude.ai/code/session_01USgemLt4Rnz4SGB1Srf3GB

…he server

#1330 broke the wallet build on main. `lib/federationServer.ts` imported
`getNetwork` from `lib/network.ts`, which imports `@veil/sdk`, whose entry
exports a React hook — so the route handler became a React Server Component
importing `useEffect`:

    You're importing a module that depends on `useEffect` into a React Server
    Component module.
    ./lib/federationServer.ts
    ./app/api/federation/route.ts

`npx tsc --noEmit` passed throughout, which is why review and CI's typecheck
both missed it; only `next build` fails. Production was never broken — the
failed build simply never deployed, so app.useveilapp.xyz kept serving the
previous one. That is also why /api/federation was still answering with
Next's HTML 404 after the merge.

Reads the two network fields this module needs from the environment instead,
mirroring `NETWORKS` in `lib/network.ts`, with one deliberate difference:
`resolveMainnetRpcUrl()` there returns the same-origin proxy `/api/rpc/mainnet`
and an empty string when there is no `window` — which is always, on the
server. So mainnet reads `MAINNET_RPC_URL`, the upstream that proxy itself
uses, rather than asking the server to proxy to itself.

An unset RPC URL now returns null explicitly rather than relying on the
catch-all, so "no RPC configured" and "RPC said no" reach the caller the same
way: a 404, which is the honest half of what is true.

`npm run build` compiles; 32 federation tests still pass.

Claude-Session: https://claude.ai/code/session_01USgemLt4Rnz4SGB1Srf3GB
@vercel

vercel Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
veil Ready Ready Preview Nov 8, 2026 9:39am UTC
veil-2ap8 Ready Ready Preview Nov 8, 2026 9:39am UTC
veil-ezry Ready Ready Preview Nov 8, 2026 9:39am UTC

@Miracle656
Miracle656 merged commit 09fc5e4 into main Nov 8, 2026
12 of 17 checks passed
@Miracle656
Miracle656 deleted the fix/federation-server-build branch November 8, 2026 09:34

This branch was successfully deployed

3 active deployments
Preview – veil — 7736bad6 Deployed Nov 8, 2026 by vercel[bot]
Preview – veil-ezry — 7736bad6 Deployed Nov 8, 2026 by vercel[bot]
Preview – veil-2ap8 — 7736bad6 Deployed Nov 8, 2026 by vercel[bot]
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