improve(svm): extract code/wasClean from Solana WS close and route log level#3427
Merged
Merged
Conversation
The reconnect path was logging the raw SolanaError cause, which is a
WebSocket CloseEvent. CloseEvent exposes code/wasClean/reason as
prototype getters, so winston serializes the cause as {} (or "[object
CloseEvent]") and the only useful fields are dropped. The Slack
transport's deep walker does pick them up, which is why we could see
1006/1011 in Slack but not in GCP logs.
Project code/wasClean/reason onto own properties before logging, drop
the rest of the CloseEvent, and route by the extracted signal: 1006
with wasClean=false is the documented Chainstack shared-gateway
rotation (https://docs.chainstack.com/docs/error-reference) -- demote
to debug. Everything else (notably 1011 Internal Error from Alchemy,
which dominates current warn volume) stays at warn.
…gling @solana/kit doesn't expose a CloseEvent helper, but `CloseEvent` is a global TypeScript type via @types/node + undici-types (the kit websocket channel uses globalThis.WebSocket, whose close event is the undici CloseEvent). Replace the manual property-by-property extraction with a single structural type guard so TS infers code/wasClean/reason from the CloseEvent interface itself. No behavioural change beyond the missing-fields edge case, which now falls through to the non-SolanaError branch (logs err.message) instead of logging undefined fields.
pxrl
approved these changes
May 28, 2026
Contributor
Author
|
Thanks for the approval. The review ( |
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.
Summary
The reconnect-on-close warn introduced in #3417 logs the raw
SolanaError.cause, which is a NodeCloseEvent.CloseEventexposescode,wasClean, andreasonas prototype getters, so winston serializes the cause as{}(Cloud Logging) or"[object CloseEvent]"(winston transport) and the only useful fields are dropped. Slack sees them only because its formatter walks the prototype — which is also why we get the giantinitEvent/stopImmediatePropagation/etc dump in the Slack message.This change projects the three scalars (
code,wasClean,reason) onto own properties before logging, drops the rest of theCloseEvent, and routes the log level on the extracted signal:code === 1006 && wasClean === false→debug. This is the documented Chainstack shared-gateway rotation at a wallclock 10-min cadence and is operational noise.code: 1011, wasClean: true, reason: "Internal Error"from Alchemy, plus unknown codes) →warn, unchanged.Empirical justification (
bots-across-3839, 7 days 2026-05-21 → 2026-05-28, bothprimary+usdh):code: 1011, wasClean: truecode: 1006, wasClean: falseSo 1006-vs-1011 is essentially a clean per-provider split: Chainstack 1006 is the wallclock-rotation noise we already know about; Alchemy 1011 is the current high-volume signal (~417/day/bot) and stays at warn so it remains alertable. The full structured log now looks like:
{ "at": "RelayerSpokePoolListenerSVM::listen", "message": "Caught error on Solana provider; reconnecting.", "provider": "wss://solana-mainnet.g.alchemy.com", "backoffS": 1, "code": 1011, "wasClean": true, "reason": "Internal Error" }…instead of the previous
cause: {}(GCP) or fullCloseEventdump (Slack).Test plan
yarn tsc --noEmitcleanyarn eslintclean on changed fileyarn prettier --checkclean on changed file#zbot-across-relayer-*Slack channels; 1011-Alchemy warns should continue to appear, now structured rather than dumped.🤖 Generated with Claude Code