Description
zx version: 8.5.4
node version: v23.10.0
os: Linux 6.14.8 #1-NixOS SMP PREEMPT_DYNAMIC Thu May 22 12:31:58 UTC 2025
A simple example:
import 'zx/globals';
const root = import.meta.dirname;
cd(root);
$.verbose = true;
await $`touch test`;
await $`grep any test`.nothrow();
console.log('regural invocation successful');
for (const line of await $`grep any test`.nothrow().lines()) {
console.log(line); // dead code
}
console.log('await .lines() invocation successful');
for await (const line of $`grep any test`.nothrow()) { // throws
console.log(line); // dead code
}
console.log('for await invocation successful'); // dead code
I think that either the async iterator behavior should match the await behavior or the docs should have a note/warning that .nothrow()
does not work on async iterators. But it would be much more convenient to have nothrow for async iterators, as grep/ugrep/rg are ubiquitous enough for that issue to be a bit annoying and async iterators are more performant memory wise (right? in the sense that I can process lines chunk by chunk rather than with a large buffer. though call independence of [Symbol.asyncIterator]
suggests that there is just some all-encompassing buffer anyway)