fix(dwn-server): validate message params before processing + improve error logging#949
Open
LiranCohen wants to merge 1 commit into
Open
fix(dwn-server): validate message params before processing + improve error logging#949LiranCohen wants to merge 1 commit into
LiranCohen wants to merge 1 commit into
Conversation
…error logging The processMessage handler destructured `message` from request params outside the try/catch block. When a client sends a request with undefined or malformed `message`, accessing `message.descriptor` throws a TypeError that crashes the server process (VM exits abruptly) instead of returning a proper JSON-RPC error. Fixes: - Validate `message.descriptor` exists before entering the try block, returning -32602 InvalidParams if missing - Improve error logging to serialize the error message and stack trace (loglevel's log.error doesn't always serialize Error objects) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
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
handleDwnProcessMessagehandler destructuredmessagefrom request params at line 27 — outside the try/catch block (which starts at line 30). When a client sends a request withundefinedor malformedmessage, accessingmessage.descriptorthrows aTypeErrorthat:Virtual machine exited abruptlyin Fly.io logs)Fix
message?.descriptorexists before entering the try block. Returns-32602 InvalidParamswith a clear message if missing.loglevel'slog.error('msg', error)doesn't reliably serialize Error objects to stdout.Root cause
Discovered while investigating
-32603errors during wallet sync. The server was crashing on requests with undefinedmessageparams, causing cascading 500s and VM restarts that made the Fly.io DWN appear unreliable. Already deployed to Fly.io for immediate relief.Test plan
-32602error instead of 500/crash🤖 Generated with Claude Code