Files
scriptc/tests/corpus/stream-dynamic-write-callback/report.js
T
Chris Tate d8f3565ac4 Call untyped write completion callbacks with the error argument
A write completion callback that a JavaScript module returned reaches
the stream lowering as an untyped value. Since the error-argument form
of write callbacks, the lowering refused it with SC2020, so
tests/corpus/8532-stream-saved-callback-receiver failed to compile.

Such a callback is now converted to a function of the error argument.
The stream calls it unbound with null after a successful write or with
the write's error, and ignores what it returns, as Node does.
2026-10-29 18:55:44 -05:00

12 lines
447 B
JavaScript

// A write completion callback built in JavaScript: it records how it was
// called. Module code is strict, so an unbound call sees `this` undefined.
export function makeReporter(lines, label) {
return function (...args) {
const error = args[0];
lines.push(
`${label} args=${args.length} error=${error === null ? "null" : error === undefined ? "undefined" : error.message} this=${typeof this}`,
);
return "ignored";
};
}