Version
main
Platform
Subsystem
sqlite
What steps will reproduce the bug?
import { Database } from 'node:sqlite';
const db = new Database(':memory:');
db.createModule('empty', {
columns: [{ name: 'value', type: 'INTEGER' }],
rows() {
return {
[Symbol.iterator]() { return this; },
next() { return { value: [], done: true }; }, // empty: exhausted immediately
return() { throw new Error('cleanup boom'); },
};
},
});
console.log(db.prepare('SELECT value FROM empty').all());
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
Once next() reports done: true, the iterator is finished and return() must be skipped, matching for...of semantics where return() is only called on abrupt termination; the query should return [].
What do you see instead?
throws Error: cleanup boom from the custom iterator's return() even though the iterable is empty and was exhausted normally.
Additional information
No response
Version
main
Platform
Subsystem
sqlite
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
Once
next()reportsdone: true, the iterator is finished andreturn()must be skipped, matchingfor...ofsemantics wherereturn()is only called on abrupt termination; the query should return[].What do you see instead?
throws
Error: cleanup boomfrom the custom iterator'sreturn()even though the iterable is empty and was exhausted normally.Additional information
No response