docs(nodejs): clarify Table.add progress dispatch semantics

This commit is contained in:
Brendan Clement
2026-05-18 09:53:20 -07:00
parent 0e393c08c9
commit 1df20aed81
3 changed files with 10 additions and 8 deletions

View File

@@ -31,9 +31,9 @@ progress: (progress) => void;
Optional callback invoked periodically with write progress.
The callback is fired once per batch written and once more with
`done: true` when the write completes. Calls are non-blocking — if the
callback is slow, intermediate updates may be dropped to avoid stalling
the write.
`done: true` when the write completes. Calls are dispatched
asynchronously to the JS event loop and never block the write — a slow
callback will queue events rather than back-pressure the writer.
Errors thrown from the callback are logged with `console.warn` and
swallowed — they do not abort the write.

View File

@@ -88,9 +88,9 @@ export interface AddDataOptions {
* Optional callback invoked periodically with write progress.
*
* The callback is fired once per batch written and once more with
* `done: true` when the write completes. Calls are non-blocking — if the
* callback is slow, intermediate updates may be dropped to avoid stalling
* the write.
* `done: true` when the write completes. Calls are dispatched
* asynchronously to the JS event loop and never block the write — a slow
* callback will queue events rather than back-pressure the writer.
*
* Errors thrown from the callback are logged with `console.warn` and
* swallowed — they do not abort the write.

View File

@@ -103,8 +103,10 @@ impl Table {
if let Some(tsfn) = progress_callback {
op = op.progress(move |p| {
// Non-blocking: drop progress events rather than back-pressuring
// the write if the JS callback can't keep up.
// NonBlocking: dispatch onto the JS event loop without
// blocking the writer thread. With napi-rs's default
// unbounded queue, events are not dropped — a slow JS
// callback will just queue them.
tsfn.call(
WriteProgressInfo::from(p),
ThreadsafeFunctionCallMode::NonBlocking,