Skip to content

fix(core): stop discarding the per-version promises in core() - #87

Merged
bnb merged 2 commits into
mainfrom
bnb/core-await-releases
Oct 20, 2026
Merged

bnb merged 2 commits into
mainfrom
bnb/core-await-releases

Conversation

@botandbang

Copy link
Copy Markdown
Contributor

core() built its data inside Object.keys(versions).map(async (version) => { ... }) (L21) and never awaited the promises before returning. The callback awaited determineCurrentReleasePhase (L129-L133), so support.lts.oldest, each release's lts and security objects, and security.newest/oldest/all all ran as later continuations. They only finished before callers saw data because determineCurrentReleasePhase is async without doing anything async. Errors thrown in the callback were swallowed too: core() resolved with partial data and the error became an unhandled rejection.

Changed: determineCurrentReleasePhase is now sync, and the .map(async ...) is now a for...of loop with the same body.

Added: core/test/errors.js checks that core() rejects when index.json has a version it can't parse. On main this test fails.

Output is unchanged: JSON from main and this branch is identical on the real index.json and schedule.json at five dates from 2016 to 2030. This conflicts with #86 on the first line of the loop. Resolve it by keeping the for line from here and the coerce change from #86.

core() built its data in an unawaited `.map(async ...)`, so everything
after the `await determineCurrentReleasePhase(...)` ran as a later
continuation and errors became unhandled rejections. determineCurrentReleasePhase
is now sync and the loop is a plain for...of, so core() rejects on errors
and returns fully built data.
@bnb
bnb merged commit bd96a20 into main Oct 20, 2026
18 checks passed
@bnb
bnb deleted the bnb/core-await-releases branch October 20, 2026 21:55
@github-actions github-actions Bot mentioned this pull request Oct 20, 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