Skip to content

fix(csv-stringify): report record access errors through streams - #566

Open
krish-goradia wants to merge 1 commit into
adaltas:masterfrom
krish-goradia:fix/stringify-record-access-errors
Open

krish-goradia wants to merge 1 commit into
adaltas:masterfrom
krish-goradia:fix/stringify-record-access-errors

Conversation

@krish-goradia

Copy link
Copy Markdown

Fixes #565.

A record getter or Proxy can throw during field access or automatic column discovery. Those exceptions currently escape _transform; with the callback API they escape the scheduled writer and terminate the process without calling the supplied error callback. Direct write() also throws despite an attached stream error listener.

Catch exceptions from the record transformation and pass them through the existing transform callback and stop state, just as returned casting errors are handled. Keep the transform callback outside the try block.

Six subprocess checks cover getters and column-discovery traps through callback, direct-write, and pipeline APIs. The four callback/write cases fail before the fix; the two pipeline cases already pass and guard existing behavior. Callback checks also verify that the original error is delivered exactly once.

Validation on Node.js 26.4.0:

  • All five library packages: 1,078 passing, 5 pending (lerna run test scoped to csv, csv-generate, csv-parse, csv-stringify, and stream-transform), including TypeScript checks.
  • ESLint passes for both changed files.
  • csv-stringify build passes; rebuilt CommonJS and ESM bundles deliver the original getter error to the callback. Generated distributions are left to the release build process.
  • The full repository test command does not complete locally: the unrelated demo/issues-esm/lib/441.js example cannot load DuckDB's native binding after dependency installation with scripts disabled. The library package run above passes independently.

AI assistance: Codex helped reproduce the bug, implement the fix, write the tests, and prepare this description.

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.

csv-stringify: record getter exceptions escape the callback and stream error paths

1 participant