Skip to content

fix: accept null value in QueryUpdated messages - #1

Open
moshemarciano wants to merge 1 commit into
un:mainfrom
moshemarciano:fix/query-updated-null-value
Open

fix: accept null value in QueryUpdated messages#1
moshemarciano wants to merge 1 commit into
un:mainfrom
moshemarciano:fix/query-updated-null-value

Conversation

@moshemarciano

Copy link
Copy Markdown

Summary

Fixes an infinite WebSocket reconnect loop caused by the SDK rejecting QueryUpdated messages where value is null.

Problem

When a Convex query returns no results, the server sends a Transition message with a QueryUpdated modification where value: null. The SDK's StateModification.UnmarshalJSON treats a nil value as a protocol error:

protocol decode failure: invalid Transition server message: query updated modification missing value

This triggers onProtocolFailure → reconnect → same message arrives → infinite loop (reconnecting every ~100ms).

Fix

Default value to json.RawMessage("null") when the field is nil, instead of returning an error. A JSON null is a valid value — it unmarshals through Value correctly (becomes a nil-valued Value).

Testing

  • Added TestStateModificationQueryUpdatedNullValue — verifies {"type":"QueryUpdated","queryId":1,"value":null} decodes successfully with value "null"
  • All existing tests pass (8 packages, 0 failures)

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.
@CLAassistant

CLAassistant commented Apr 19, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

2 participants