Open rhashimoto opened 3 years ago
Good catch ! Are you interested in making a PR ?
@lovasoa Honestly I find it difficult to work in the sql.js tree because the coding standard is ES5 and you have to run emcc for changes that only affect the Javascript side. If you can get someone to help improve the project infrastructure, it would be a lot easier to dash off a fix - I would do it even though I can't use it (I need an asynchronous API).
A statement provided by StatementIterator can be leaked until the Database is closed if the iterator is not run to completion. A statement is not freed until
next
is called for the following iteration, which might not happen if, for example, afor...of
loop is exited viabreak
,return
, or thrown exception.Careful coding can work around this issue, but that code will also be uglier and harder to read. A better fix would be to implement the optional
return
method on the iterator to reclaim its resources, as that will be automatically called on early loop termination.