docs: fix Node.js quickstart scope handle and LLM request usage#196
docs: fix Node.js quickstart scope handle and LLM request usage#196zhongxuanwang-nv wants to merge 1 commit into
Conversation
The Node.js quick start and the nemo-relay-node package README passed the
informational handle from `withScope` straight into `event`, `toolCallExecute`,
and `llmCallExecute`. Those APIs expect either `null` (the current scope) or a
real `ScopeHandle`, so the plain handle object failed with "Failed to recover
`ScopeHandle` type from napi value" on the first call. The rejected promise then
skipped `deregisterSubscriber`, leaving the subscriber's ThreadsafeFunction
ref'd and hanging the process.
The LLM example also built the request with `new LlmRequest(...)`, but
`llmCallExecute` takes a plain `{ headers, content }` JSON object.
Update both examples to pass `null` for the active scope and a plain request
object, matching the behavior covered by the Node binding tests.
Signed-off-by: Zhongxuan Wang <daniewang@nvidia.com>
WalkthroughThis PR updates Node.js documentation and examples to demonstrate correct scope-targeting semantics. The quick-start guide removes ChangesDocumentation: Scope-targeting semantics and LlmRequest simplification
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/node/README.md`:
- Line 80: Update the explanatory comment that mentions handle to wrap the
literal null in inline code formatting; specifically change the comment "//
`handle` describes the active scope; pass null to target the current scope." so
that the word null is surrounded by backticks (i.e., `null`) to match
documentation formatting and coding guidelines for code elements.
In `@docs/getting-started/quick-start/nodejs.mdx`:
- Line 60: The sentence "For lifecycle calls inside the scope, pass null to
target the current scope." should format the literal null as inline code; update
the docs text in docs/getting-started/quick-start/nodejs.mdx so that `null` is
wrapped in backticks (i.e., change the plain word null to a monospace code
element) to follow the project's docs formatting guidelines for code elements.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: 747dbda6-9d62-47e3-bb0b-0a004321b7d9
📒 Files selected for processing (2)
crates/node/README.mddocs/getting-started/quick-start/nodejs.mdx
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Check / Run
- GitHub Check: Preview docs
🧰 Additional context used
📓 Path-based instructions (22)
**/*.{md,rst,html,txt}
📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-brand-terminology.md)
**/*.{md,rst,html,txt}: Always spellNVIDIAin all caps. Do not useNvidia,nvidia,nVidia,nVIDIA, orNV.
Usean NVIDIAbefore a noun because the name starts with an 'en' sound.
Do not add a registered trademark symbol afterNVIDIAwhen referring to the company.
Use trademark symbols with product names only when the document type or legal guidance requires them.
Verify official capitalization, spacing, and hyphenation for product names.
Precede NVIDIA product names withNVIDIAon first mention when it is natural and accurate.
Do not rewrite product names for grammar or title-case rules.
Preserve third-party product names according to the owner's spelling.
Include the company name and full model qualifier on first use when it helps identify the model.
Preserve the official capitalization and punctuation of model names.
Use shorter family names only after the full name is established.
Spell out a term on first use and put the acronym in parentheses unless the acronym is widely understood by the intended audience.
Use the acronym on later mentions after it has been defined.
For long documents, reintroduce the full term if readers might lose context.
Form plurals of acronyms withs, not an apostrophe, such asGPUs.
In headings, common acronyms can remain abbreviated. Spell out the term in the first or second sentence of the body.
Common terms such asCPU,GPU,PC,API, andUIusually do not need to be spelled out for developer audiences.
Files:
crates/node/README.md
**/*.{md,rst,html}
📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-brand-terminology.md)
Link the first mention of a product name when the destination helps the reader.
Files:
crates/node/README.md
**/*.md
📄 CodeRabbit inference engine (.agents/skills/contribute-integration/SKILL.md)
Documentation must be updated if activation or usage changed
**/*.md: Use title case consistently in technical documentation headings
Avoid quotation marks, ampersands, and exclamation marks in headings
Keep product, event, research, and whitepaper names in their official title case
Use title case for table headers
Do not force social-media sentence case into technical docs
Format code elements, commands, parameters, package names, and expressions in monospace
Format directories, file names, and paths in monospace using backticks
Use angle brackets inside monospace for variables inside paths, such as/home/<username>/.login
Format error messages and strings in quotation marks, keeping literal code strings in code formatting when clearer
Format UI buttons, menus, fields, and labels in bold
Use angle brackets between UI labels for menu paths, such as File > Save As
Use italics for new terms on first use, sparingly and only when introducing the term
Use italics for publication titles
Format keyboard shortcuts in plain text, such as Press Ctrl+Alt+Delete
Use owner/repo link text for GitHub repositories, preferring[NVIDIA/NeMo](link)over prose references like 'the GitHub repo'
Introduce every code block with a complete sentence
Do not make a code block complete the grammar of the previous sentence
Do not continue a sentence after a code block
Use syntax highlighting when the format supports it for code blocks
Avoid the word 'snippet' unless the surrounding docs already use it as a term of art
Keep inline method, function, and class references consistent with nearby docs, omitting empty parentheses for prose readability when no call is shown
Use descriptive anchor text that matches the destination title when possible for links
Avoid raw URLs in running text
Avoid generic anchor text such as 'here,' 'this page,' and 'read more'
Include acronyms in link text when a linked term includes an acronym
Do not link long sentences or multiple sentences
Avoid links ...
Files:
crates/node/README.md
{crates/adaptive/**,python/nemo_relay/adaptive.py,python/nemo_relay/plugin.py,go/nemo_relay/adaptive/**,go/nemo_relay/!(adaptive)/**,**/node/**,**/wasm/**}
📄 CodeRabbit inference engine (.agents/skills/maintain-optimizer/SKILL.md)
Keep adaptive surface in sync across crates/adaptive, shared plugin behavior in core and bindings, Python adaptive/plugin wrappers in python/nemo_relay/adaptive.py and python/nemo_relay/plugin.py, Go adaptive helpers under go/nemo_relay/adaptive plus shared plugin helpers in go/nemo_relay, and Node/WebAssembly adaptive helpers and plugin wrappers
Files:
crates/node/README.md
{crates/adaptive/**,python/nemo_relay/plugin.py,go/nemo_relay/**,**/node/**,**/wasm/**}
📄 CodeRabbit inference engine (.agents/skills/maintain-optimizer/SKILL.md)
{crates/adaptive/**,python/nemo_relay/plugin.py,go/nemo_relay/**,**/node/**,**/wasm/**}: Maintain consistent plugin lifecycle across all language bindings (Python, Go, Node/WebAssembly, and Rust)
Keep plugin context surfaces aligned across all language implementations
Files:
crates/node/README.md
**/{docs,examples,**/*.md,*.patch,*.diff,.github,*.sh,*.yaml,*.yml}
📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)
Update documentation, examples, CI configuration, and patch artifacts when performing rename operations
Files:
crates/node/README.md
**/*.{md,rst,txt}
📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-guide.md)
Spell
NVIDIAin all caps. Do not useNvidia,nvidia, orNV.
Files:
crates/node/README.md
**/*.{md,rst}
📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-guide.md)
**/*.{md,rst}: Format commands, code elements, expressions, package names, file names, and paths as inline code.
Use descriptive link text. Avoid raw URLs and weak anchors such as "here" or "read more."
Use title case consistently for technical documentation headings.
Introduce code blocks, lists, tables, and images with complete sentences.
Write procedures as imperative steps. Keep steps parallel and split long procedures into smaller tasks.
Prefer active voice, present tense, short sentences, contractions, and plain English.
Usecanfor possibility and reservemayfor permission.
Useafterfor temporal relationships instead ofonce.
Preferrefer tooverseewhen the wording points readers to another resource.
Avoid culture-specific idioms, unnecessary Latinisms, jokes, and marketing exaggeration in technical docs.
Spell out months in body text, avoid ordinal dates, and use clear time zones.
Spell out whole numbers from zero through nine unless they are technical values, parameters, versions, or UI values.
Use numerals for 10 or greater and include commas in thousands.
Do not add trademark symbols to learning-oriented docs unless the source, platform, or legal guidance explicitly requires them.
Files:
crates/node/README.md
{docs/**,README.md,CONTRIBUTING.md,**/*.md}
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
Run docs link validation with
just docs-linkcheckwhen links change
Files:
crates/node/README.mddocs/getting-started/quick-start/nodejs.mdx
{docs/**,README.md,**/Cargo.toml,**/package.json,**/*.md}
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
Ensure renamed public surfaces are reflected consistently in manifests and docs for large or public-facing changes
Files:
crates/node/README.mddocs/getting-started/quick-start/nodejs.mdx
**/*.{md,mdx,py,sh,yaml,yml,toml,json}
📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)
Keep package names, repo references, and build commands current
Files:
crates/node/README.mddocs/getting-started/quick-start/nodejs.mdx
**/*.{html,md,mdx}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Include SPDX license header in HTML and Markdown files using HTML comment syntax
Files:
crates/node/README.mddocs/getting-started/quick-start/nodejs.mdx
**/README.md
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Update relevant crate or package README when that surface changed
Files:
crates/node/README.md
**/*.{rs,py,js,ts,tsx,jsx,go,sh,toml,yaml,yml,md}
📄 CodeRabbit inference engine (AGENTS.md)
Keep SPDX headers on source, docs, scripts, and configuration files. The project is Apache-2.0.
Files:
crates/node/README.md
crates/{python,ffi,node,wasm}/**/*
⚙️ CodeRabbit configuration file
crates/{python,ffi,node,wasm}/**/*: Treat binding changes as public API changes. Check for parity with the other language bindings, FFI ownership/lifetime safety,
callback error propagation, stable type conversion, and consistent async/stream semantics.
Flag changes that update one binding without corresponding tests or documentation for the same surface elsewhere.
Files:
crates/node/README.md
{docs/**,README.md,CONTRIBUTING.md}
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
{docs/**,README.md,CONTRIBUTING.md}: For docs-only changes, run targeted checks only if commands, package names, or examples changed. Usejust docsfor docs-site builds andjust docs-linkcheckwhen links changed
Run docs site build withjust docs
Files:
docs/getting-started/quick-start/nodejs.mdx
{docs/**,README.md}
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
Verify README and docs entry points still match current package names and paths for large or public-facing changes
Files:
docs/getting-started/quick-start/nodejs.mdx
{docs/**,examples/**,README.md}
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
Verify examples still run with documented commands for large or public-facing changes
Files:
docs/getting-started/quick-start/nodejs.mdx
**/*.mdx
📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)
In MDX files, top-of-file comments must use JSX comment delimiters: {/* to open and */} to close. Do not use HTML comments for MDX SPDX headers.
MDX top-of-file SPDX comments must use {/* ... */} delimiters instead of HTML comment delimiters (Must-Fix)
Files:
docs/getting-started/quick-start/nodejs.mdx
docs/**/*.{md,mdx}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Update embedded documentation snippets, patch docs, and binding-support notes if examples or supported bindings changed
Files:
docs/getting-started/quick-start/nodejs.mdx
docs/**
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Run
just docsor./scripts/build-docs.sh htmlto regenerate ignored Fern API reference pages before validation for documentation site changes
Files:
docs/getting-started/quick-start/nodejs.mdx
{docs/**,README.md,CONTRIBUTING.md,RELEASING.md,SECURITY.md}
⚙️ CodeRabbit configuration file
{docs/**,README.md,CONTRIBUTING.md,RELEASING.md,SECURITY.md}: Review documentation for technical accuracy against the current API, command correctness, and consistency across language bindings.
Flag stale examples, missing SPDX headers where required, and instructions that no longer match CI or pre-commit behavior.
Files:
docs/getting-started/quick-start/nodejs.mdx
|
|
||
| await withScope("demo-agent", ScopeType.Agent, async (handle) => { | ||
| event("initialized", handle, { binding: "node" }, null); | ||
| // `handle` describes the active scope; pass null to target the current scope. |
There was a problem hiding this comment.
Use inline code formatting for null in the explanatory comment.
Wrap null in backticks for consistency with documentation code-element formatting rules.
As per coding guidelines, "Format commands, code elements, expressions, package names, file names, and paths as inline code."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/node/README.md` at line 80, Update the explanatory comment that
mentions handle to wrap the literal null in inline code formatting; specifically
change the comment "// `handle` describes the active scope; pass null to target
the current scope." so that the word null is surrounded by backticks (i.e.,
`null`) to match documentation formatting and coding guidelines for code
elements.
| await withScope("demo-agent", ScopeType.Agent, async (handle) => { | ||
| event("initialized", handle, { binding: "node" }, null); | ||
| // `handle` describes the active scope (handle.uuid, handle.name, handle.scopeType). | ||
| // For lifecycle calls inside the scope, pass null to target the current scope. |
There was a problem hiding this comment.
Format null as inline code in prose comments.
Use backticks around null in this sentence to keep code elements consistently formatted in docs.
As per coding guidelines, "Format code elements, commands, parameters, package names, and expressions in monospace."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/getting-started/quick-start/nodejs.mdx` at line 60, The sentence "For
lifecycle calls inside the scope, pass null to target the current scope." should
format the literal null as inline code; update the docs text in
docs/getting-started/quick-start/nodejs.mdx so that `null` is wrapped in
backticks (i.e., change the plain word null to a monospace code element) to
follow the project's docs formatting guidelines for code elements.
willkill07
left a comment
There was a problem hiding this comment.
Manually specifying a handle should work though. What was the raised panic?
@willkill07 Hey Will, yes I think manually specifying a handle does work; here it's mainly a rejected Promise / thrown napi error; I should've included the error output: And then it's stuck there forever. It's because Therefore, I made |
Overview
The Node.js quick start and the
nemo-relay-nodepackage README shipped an example that crashed and then hung. This corrects both examples so the documented workflow runs to completion and exits cleanly. No runtime/binding behavior changes; this is a docs-only correction aligned with the contract the Node binding tests already exercise.Details
The examples passed the informational handle returned by
withScopedirectly intoevent,toolCallExecute, andllmCallExecute. Those APIs accept eithernull(target the current scope) or a realScopeHandle; the plain handle object cannot be recovered, so the first call threwinternal error: Failed to recover ScopeHandle type from napi value. Because that rejection skippedderegisterSubscriber, the subscriber'sThreadsafeFunctionstayed referenced and the process hung instead of exiting.The LLM example also built the request with
new LlmRequest({}, { ... }), butllmCallExecuteexpects a plain{ headers, content }JSON object, so the request content was dropped.Changes:
docs/getting-started/quick-start/nodejs.mdx: passnullfor the active scope inevent/toolCallExecute/llmCallExecute, send the LLM request as a plain{ headers, content }object, and drop the now-unusedLlmRequestimport.crates/node/README.md: passnullinstead of the handle in theeventsnippet.Validation:
{ echo: 'hello' }, and the LLM result, then exits0with no hang.uv run pre-commit run --files crates/node/README.md docs/getting-started/quick-start/nodejs.mdxpassed (copyright header, markdown linkcheck, formatting).Where should the reviewer start?
Start with
docs/getting-started/quick-start/nodejs.mdx— thewithScopecallback body shows the corrected handle argument (null) and the plain{ headers, content }request. Cross-check againstcrates/node/tests/scope_tests.mjs(thewithScopehandle is informational) andcrates/node/tests/llm_tests.mjs(makeNative()returns a plain{ headers, content }object), which is the behavior the docs now match.Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
Summary by CodeRabbit