- Version: v12.4.0
- Platform: Darwin hostname.local 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
- Subsystem: Stream
The async iterator functionality relies on a private API on destroy that accepts a second argument which is a callback. See here:
return() {
// destroy(err, cb) is a private API.
// We can guarantee we have that here, because we control the
// Readable class this is attached to.
return new Promise((resolve, reject) => {
this[kStream].destroy(null, (err) => {
if (err) {
reject(err);
return;
}
resolve(createIterResult(undefined, true));
});
});
}
This private API is not present on objects derived from Readable that have _destroy overridden. This means that premature exit from a for await loop which triggers the above return method will cause the program to end after running out of async continuations, as the callback is never called.
The async iterator functionality relies on a private API on
destroythat accepts a second argument which is a callback. See here:This private API is not present on objects derived from
Readablethat have_destroyoverridden. This means that premature exit from afor awaitloop which triggers the abovereturnmethod will cause the program to end after running out of async continuations, as the callback is never called.