fix: accept null value in QueryUpdated messages - #1
Open
moshemarciano wants to merge 1 commit into
Open
Conversation
Convex sends QueryUpdated with value=null when a query returns no results. The SDK rejected this with "query updated modification missing value", which triggered an infinite WebSocket reconnect loop because the same message arrived after every reconnect. Replace the nil-value rejection with a fallback to literal JSON null, matching the wire representation and preventing the reconnect loop.
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
Fixes an infinite WebSocket reconnect loop caused by the SDK rejecting
QueryUpdatedmessages wherevalueisnull.Problem
When a Convex query returns no results, the server sends a
Transitionmessage with aQueryUpdatedmodification wherevalue: null. The SDK'sStateModification.UnmarshalJSONtreats a nilvalueas a protocol error:This triggers
onProtocolFailure→ reconnect → same message arrives → infinite loop (reconnecting every ~100ms).Fix
Default
valuetojson.RawMessage("null")when the field is nil, instead of returning an error. A JSONnullis a valid value — it unmarshals throughValuecorrectly (becomes a nil-valuedValue).Testing
TestStateModificationQueryUpdatedNullValue— verifies{"type":"QueryUpdated","queryId":1,"value":null}decodes successfully with value"null"