Skip to content

fix(node): forward streamAllMessages errors to JavaScript callbacks#3837

Draft
XHFkindergarten wants to merge 1 commit into
xmtp:mainfrom
XHFkindergarten:fix/node-stream-all-messages-errors
Draft

fix(node): forward streamAllMessages errors to JavaScript callbacks#3837
XHFkindergarten wants to merge 1 commit into
xmtp:mainfrom
XHFkindergarten:fix/node-stream-all-messages-errors

Conversation

@XHFkindergarten

@XHFkindergarten XHFkindergarten commented Jul 10, 2026

Copy link
Copy Markdown

Summary

Forward per-item SubscribeError values emitted by
Conversations::stream_all_messages to the Node N-API callback instead of
logging and discarding them.

The stream continues consuming subsequent items after reporting the error.

Context

#899 and #1182 introduced stream error propagation so external SDKs could
observe and handle failures.

#1938 later made stream_all_messages a special case: errors are logged and
discarded before crossing the N-API boundary. At that time the Node
AsyncStream ended when an error reached it. xmtp-js #1118 subsequently
changed that behavior: item errors are passed to onError and the stream
remains active.

As a result, the original reason for suppressing these errors no longer
applies. Keeping the suppression now makes the Node SDK's onError handler
unreachable for aggregate message-stream item errors, while conversation,
single-conversation message, consent, preference, Mobile, and WASM streams
still expose their errors.

This makes failures associated with reports such as #2351 and #3541 silent to
Node applications and prevents consumers from applying an explicit recovery
policy.

Behavior

Before:

Rust stream item Err -> warning log -> no JavaScript callback

After:

Rust stream item Err -> callback(error, undefined) -> stream continues

There is no public API signature change.

Scope

This PR restores observability at the Node binding boundary. It does not claim
to fix the underlying transport or MLS delivery omissions tracked by #2351 and
#3541, and it does not change cursor or retry behavior.

Verification

  • cargo check --locked -p bindings_node --lib
  • yarn workspace @xmtp/node-sdk test test/streams.test.ts
  • eslint node-sdk/test/streams.test.ts

Refs #899, #1182, #1938, #2351, #3541.

Note

Forward streamAllMessages errors to JavaScript callbacks instead of silently skipping them

  • Previously, message-level errors in the Conversations.stream async method were logged and dropped; the JS callback never received them.
  • Now, both Ok and Err results are forwarded to the JS ThreadsafeFunction via ErrorWrapper, so callers can handle per-item failures without the stream terminating.
  • A new test in streams.test.ts verifies that item errors are reported to onError while subsequent values are still delivered and onFail is not called.
  • Behavioral Change: callbacks that previously only received successful messages will now also receive error results for failed items.

Macroscope summarized 34a1b14.

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.18%. Comparing base (6943ad2) to head (34a1b14).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3837   +/-   ##
=======================================
  Coverage   85.18%   85.18%           
=======================================
  Files         412      412           
  Lines       64132    64132           
=======================================
  Hits        54630    54630           
  Misses       9502     9502           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant