Repository navigation
fix(wallet): stop the federation route pulling a client module into the server - #1331
Merged
Merged
Conversation
…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
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#1330 broke the wallet build on
main.lib/federationServer.tsimportedgetNetworkfromlib/network.ts, whichimports
@veil/sdk, whose entry exports a React hook. That made the routehandler a React Server Component importing
useEffect:npx tsc --noEmitpasses throughout — onlynext buildcatches it, which ishow 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/federationwas still answering with Next's HTML 404 after #1330 merged.The #1329 security fix had already deployed and is live (
/api/names/availablereturns 503).
The fix
Reads the two network fields this module needs from the environment, mirroring
NETWORKSinlib/network.ts, with one deliberate difference:resolveMainnetRpcUrl()there returns the same-origin proxy/api/rpc/mainnetand 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, ratherthan 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— cleanhttps://claude.ai/code/session_01USgemLt4Rnz4SGB1Srf3GB