Skip to content

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

Open
Jr-kenny wants to merge 1 commit into
xmtp:mainfrom
Jr-kenny:Jrkenny/fix-3844-node-stream-errors
Open

fix(node): forward streamAllMessages errors to JavaScript callbacks#4000
Jr-kenny wants to merge 1 commit into
xmtp:mainfrom
Jr-kenny:Jrkenny/fix-3844-node-stream-errors

Conversation

@Jr-kenny

@Jr-kenny Jr-kenny commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

What this does

Conversations::stream_all_messages was logging a SubscribeError and returning before it reached the Node callback. That quietly threw away item errors from the Node SDK, even though the stream itself was still alive.

The binding now forwards both successful messages and errors through the existing ThreadsafeFunction. An item error reaches JavaScript as (error, undefined), and later items can still reach onValue.

Why

The other Node stream adapters already pass their errors through. createStream treats an item error as onError and keeps the stream running, so stream_all_messages was the odd path that never let the error reach JavaScript.

I added the Node contract test and a Rust adapter regression test. I also put the old early return back temporarily and ran the Rust test against it. It failed with zero callbacks. After removing the return, the same test passed with one callback.

This keeps the change at the binding boundary. It doesn't change retry, cursor advancement, transport delivery, or MLS behavior.

Testing

  • cargo fmt --check
  • cargo check --locked -p bindings_node --lib
  • cargo clippy --locked --package bindings_node --lib --all-features -- -D warnings
  • Rust regression test with the old behavior and the fixed behavior
  • Native Node binding build
  • yarn workspace @xmtp/node-sdk test test/streams.test.ts (18/18)
  • yarn workspace @xmtp/node-sdk typecheck
  • yarn eslint node-sdk/test/streams.test.ts
  • git diff --check

Fixes #3844

Note

Forward streamAllMessages item-level errors to JavaScript callbacks in Node bindings

  • Previously, errors from individual messages in stream_all_messages_with_callback_dispatch were silently dropped in the Node bindings; they are now forwarded to the JS callback as napi::Error.
  • Adds a forward_message helper in streams.rs that maps StoredGroupMessage results to Message and wraps errors via ErrorWrapper, invoking the callback for both success and failure.
  • Adds a Node SDK integration test in streams.test.ts verifying that item-level errors trigger onError without blocking subsequent successful messages.
  • Behavioral Change: JS stream consumers will now receive errors via the callback where previously those errors were silently ignored.

Macroscope summarized b1da857.

@Jr-kenny
Jr-kenny marked this pull request as ready for review August 14, 2026 21:54
@Jr-kenny
Jr-kenny requested a review from a team as a code owner August 14, 2026 21:54
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.00%. Comparing base (da3e3c5) to head (b1da857).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4000   +/-   ##
=======================================
  Coverage   86.00%   86.00%           
=======================================
  Files         417      417           
  Lines       68165    68165           
=======================================
  Hits        58622    58622           
  Misses       9543     9543           

☔ 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.

XMTP Node stream error

1 participant