Skip to content

fix(node): isolate throwing codec callbacks - #1529

Merged
greysonlalonde merged 1 commit into
NVIDIA:mainfrom
greysonlalonde:fix/node-codec-callback-abort
Oct 26, 2026
Merged

greysonlalonde merged 1 commit into
NVIDIA:mainfrom
greysonlalonde:fix/node-codec-callback-abort

Conversation

@greysonlalonde

@greysonlalonde greysonlalonde commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Overview

A JavaScript codec callback may throw while Relay processes an LLM event. In some cases, this error stops the Node.js process instead of returning a normal error. This change isolates codec callback failures.

  • I confirm this contribution is my own work, or I have the right to submit it under this project's license.
  • I searched existing issues and open pull requests, and this does not duplicate existing work.

Details

  • add JsCodecCallback and build NapiCodec and NapiResponseCodec from it in crates/node/src/callable.rs
  • remove recv_llm_request_result from crates/node/src/callable.rs
  • rewire node_llm_codec and node_llm_response_codec and extend the llmCall docstring in crates/node/src/api/mod.rs
  • add codec callback failure tests to crates/node/tests/llm_tests.mjs

Where should the reviewer start?

Start with JsCodecCallback::new, JsCodecCallback::call, and JsCodecCallback::invoke in crates/node/src/callable.rs. These methods handle callback execution, result validation, and error reporting.
Next, review the NapiCodec and NapiResponseCodec implementations in the same file.
Then review node_llm_codec and node_llm_response_codec in crates/node/src/api/mod.rs.
Finally, review the LLM codec callback failures tests in crates/node/tests/llm_tests.mjs.

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

Summary by CodeRabbit

  • Bug Fixes
    • LLM calls now continue publishing when response decoding fails or produces an invalid annotation; the annotation is skipped and the callback error is recorded.
    • Request decoding or encoding callback failures reject execution with callback-specific errors.
    • Response decoding failures are recorded without rejecting the call or adding an annotated response to the completion event.

- add JsCodecCallback and build NapiCodec and NapiResponseCodec from it in crates/node/src/callable.rs
- remove recv_llm_request_result from crates/node/src/callable.rs
- rewire node_llm_codec and node_llm_response_codec and extend the llmCall docstring in crates/node/src/api/mod.rs
- add codec callback failure tests to crates/node/tests/llm_tests.mjs

Signed-off-by: Greyson Lalonde <[email protected]>
@greysonlalonde greysonlalonde added this to the 0.11 milestone Oct 26, 2026
@greysonlalonde greysonlalonde self-assigned this Oct 26, 2026
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 6c4409b and d0a44f1.

Files selected for processing: 3
  • crates/node/src/api/mod.rs
  • crates/node/src/callable.rs
  • crates/node/tests/llm_tests.mjs

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Recent review details
Context from checks skipped due to timeout: 19
  • GitHub Check: Node.js / Test (windows-arm64)
  • GitHub Check: Node.js / Package OpenClaw plugin
  • GitHub Check: Node.js / Test (linux-amd64)
  • GitHub Check: Node.js / Package (windows-arm64)
  • GitHub Check: Node.js / Package (linux-arm64)
  • GitHub Check: Node.js / Package (macos-arm64)
  • GitHub Check: Node.js / Package (linux-musl-arm64)
  • GitHub Check: Node.js / Package (windows-amd64)
  • GitHub Check: Node.js / Test (linux-arm64)
  • GitHub Check: Node.js / Test (windows-amd64)
  • GitHub Check: Node.js / Test (macos-arm64)
  • GitHub Check: Rust / Test (macos-arm64)
  • GitHub Check: Node.js / Package (linux-musl-amd64)
  • GitHub Check: Node.js / Package (linux-amd64)
  • GitHub Check: Rust / Test (linux-amd64)
  • GitHub Check: Rust / Test (windows-amd64)
  • GitHub Check: Rust / Test (linux-arm64)
  • GitHub Check: Rust / Test (windows-arm64)
  • GitHub Check: Check / Run
Additional context used
Code guidelines: 1
.agents/skills/contribute-integration/SKILL.md — configured
Path-based instructions: 3
Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.

CodeRabbit configuration file

Files:

  • crates/node/tests/llm_tests.mjs
Treat binding changes as public API changes.

CodeRabbit configuration file

Files:

  • crates/node/src/api/mod.rs
  • crates/node/tests/llm_tests.mjs
  • crates/node/src/callable.rs
Source excerpt: Keep NeMo Relay optional Source excerpt: Use stable, documented framework or plugin APIs Source excerpt: Wrap tool and LLM paths at the correct framework boundary Source excerpt: Preserve the framework's original behavior wh...

CodeRabbit inference engine (.agents/skills/contribute-integration/SKILL.md)

Files:

  • crates/node/src/api/mod.rs
  • crates/node/tests/llm_tests.mjs
  • crates/node/src/callable.rs
Additional comments: 2
crates/node/src/api/mod.rs: 1

2213-2213: LGTM!

Also applies to: 2387-2397

crates/node/tests/llm_tests.mjs: 1

484-640: LGTM!

Walkthrough

Node LLM request and response codecs now use shared JavaScript callback dispatch. The changes add callback error handling and tests for failures during manual calls and execution.

Changes

Node LLM codec callbacks

Layer / File(s) Summary
Shared callback dispatch
crates/node/src/callable.rs
A shared callback wrapper handles direct and threadsafe JavaScript calls, argument serialization, result deserialization, and callback errors. Request and response codec adapters use the wrapper.
Codec wiring and failure behavior
crates/node/src/api/mod.rs, crates/node/tests/llm_tests.mjs
Node LLM codec setup constructs and retains callback wrappers. Tests cover decode and encode failures, callback error recording, emitted events, and request or provider-result behavior. The llm_call documentation describes decode failures and invalid values.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: Minimal · up to d0a44

Unsupported codec callback results are handled as errors rather than terminating Node. No actionable merge-blocking risk remains after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title follows Conventional Commits format with the allowed type fix, lowercase scope node, an imperative summary, and 43 characters without a trailing period.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The pull request description follows the repository template. It includes the overview, completed contribution checks, implementation details, reviewer guidance, and a related issue using the required…
Full details: Description check

Explanation

The pull request description follows the repository template. It includes the overview, completed contribution checks, implementation details, reviewer guidance, and a related issue using the required Fixes keyword.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added size:M PR is medium Bug issue describes bug; PR fixes bug lang:js PR changes/introduces Javascript/Typescript code lang:rust PR changes/introduces Rust code labels Oct 26, 2026
@greysonlalonde
greysonlalonde marked this pull request as ready for review October 26, 2026 16:55
@greysonlalonde
greysonlalonde requested a review from a team as a code owner October 26, 2026 16:55

@willkill07 willkill07 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love the structural cleanup here

@greysonlalonde
greysonlalonde enabled auto-merge (squash) October 26, 2026 17:04
@greysonlalonde
greysonlalonde merged commit a73bba3 into NVIDIA:main Oct 26, 2026
58 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Oct 30, 2026
2 tasks done

This branch was previously deployed

1 inactive deployment
fern — d0a44f16 Deployed Oct 26, 2026 by greysonlalonde via Clean up docs preview #6598
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug issue describes bug; PR fixes bug lang:js PR changes/introduces Javascript/Typescript code lang:rust PR changes/introduces Rust code size:M PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants