From 70de5c4d0d32549500c7adfcce3abfbbb62524ea Mon Sep 17 00:00:00 2001 From: botandbang <337765928+botandbang@users.noreply.github.com> Date: Tue, 20 Oct 2026 17:14:33 -0400 Subject: [PATCH] fix(core): stop discarding the per-version promises in core() 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. --- core/index.js | 12 +++++------- core/test/errors.js | 13 +++++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 core/test/errors.js diff --git a/core/index.js b/core/index.js index 88f625f0..ed333f1e 100644 --- a/core/index.js +++ b/core/index.js @@ -18,7 +18,7 @@ async function core(options) { // instantiate our data object, to be expanded upon const data = {}; - Object.keys(versions).map(async (version) => { + for (const version of Object.keys(versions)) { const versionSemver = semver.coerce(versions[version].version); const name = versionSemver.major !== 0 @@ -127,10 +127,8 @@ async function core(options) { data[name].support.phases.dates.end = schedule[name]?.end ?? undefined; } data[name].support.phases.current = - (await determineCurrentReleasePhase( - now, - data[name].support.phases.dates, - )) ?? {}; + determineCurrentReleasePhase(now, data[name].support.phases.dates) ?? + {}; } // this is a slightly inefficient way to do this but it's also easy @@ -178,12 +176,12 @@ async function core(options) { data[name].releases[`v${versionSemver.version}`].security.isSecurity = versions[version].security ?? false; - }); + } return data; } -async function determineCurrentReleasePhase(now, dates = {}) { +function determineCurrentReleasePhase(now, dates = {}) { // we set set this up to enable custom `now` passing, since passing an ISO // const usableNow = DateTime.fromISO(now) diff --git a/core/test/errors.js b/core/test/errors.js new file mode 100644 index 00000000..fca5c0a5 --- /dev/null +++ b/core/test/errors.js @@ -0,0 +1,13 @@ +const { rejects } = require('node:assert'); +const nodevu = require('../index'); +const { describe, it } = require('node:test'); + +describe('errors while building the data', async () => { + it('should reject when index.json has a version that cannot be parsed', async () => { + const index = [{ version: 'not-a-version', files: [] }]; + const fetch = async (url) => + Response.json(url.endsWith('schedule.json') ? {} : index); + + await rejects(nodevu({ fetch, now: '2024-01-01T00:00:00.000Z' })); + }); +});