Skip to content

fix: yield results from _enumerate when metaOnly is true#21

Closed
es617 wants to merge 1 commit into
vrtmrz:mainfrom
es617:fix/enumerate-metaonly-yield
Closed

fix: yield results from _enumerate when metaOnly is true#21
es617 wants to merge 1 commit into
vrtmrz:mainfrom
es617:fix/enumerate-metaonly-yield

Conversation

@es617

@es617 es617 commented Mar 24, 2026

Copy link
Copy Markdown

Problem

DirectFileManipulator._enumerate() silently returns zero results when called with metaOnly: true.

In an async * generator function, a bare return <value> doesn't yield anything to the caller — it just sets the generator's return value (which for await...of ignores). The current code returns the async iterator from findEntries() as a completion value instead of delegating to it.

// Before: returns the iterator as a value, yields nothing
async *_enumerate(startKey, endKey, opt) {
    if (opt.metaOnly) return this.liveSyncLocalDB.findEntries(startKey, endKey, {});
    // ...
}

This means enumerateAllNormalDocs({ metaOnly: true }) always produces an empty sequence.

Fix

// After: delegates to the iterator, yields all its values
if (opt.metaOnly) return yield* this.liveSyncLocalDB.findEntries(startKey, endKey, {});

yield* delegates to the inner async generator, forwarding all its values to the caller.

In `_enumerate`, the `metaOnly` branch used `return` instead of
`return yield*`, causing `enumerateAllNormalDocs({ metaOnly: true })`
to silently produce zero results. The async generator returned the
inner iterator as a value rather than delegating to it.
@es617

es617 commented Mar 26, 2026

Copy link
Copy Markdown
Author

Closing this — the original branch was based on an old commit. Reopened as #22 with the same one-line fix, now based on current main.

@es617 es617 closed this Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants