-
-
Couldn't load subscription status.
- Fork 6.4k
fix: fallback to Maintenance LTS if no Active LTS found #8251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
💡 Enable Vercel Agent with $100 free credit for automated AI reviews |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR modifies the WithNodeRelease component to support fallback behavior when searching for Node.js releases by status. Instead of accepting only a single status string, the component now accepts an array of statuses and attempts to find a matching release in order, returning the first match found.
- Changed the release matching logic from a single
find()call to a loop that tries multiple statuses in priority order - Updated call sites to pass an array of statuses (
['Active LTS', 'Maintenance LTS']) to enable fallback from Active LTS to Maintenance LTS
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/site/components/withNodeRelease.tsx | Refactored matching logic to iterate through status array and return first match |
| apps/site/components/withFooter.tsx | Updated to pass array of statuses for fallback behavior |
| apps/site/components/withDownloadSection.tsx | Updated to pass array of statuses for fallback behavior |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8251 +/- ##
==========================================
+ Coverage 76.24% 76.37% +0.13%
==========================================
Files 115 115
Lines 9643 9647 +4
Branches 318 318
==========================================
+ Hits 7352 7368 +16
+ Misses 2289 2277 -12
Partials 2 2 ☔ View full report in Codecov by Sentry. |
|
Requesting fast-track on the basis this is an emergency fix, not sure I even need to request fast-track for that |
|
"Active" and "Maintenance" LTS stages are important to the Release WG, not really for the public. The website should only care about what is the latest LTS, i.e. the one with the highest version number. |
| const matchingRelease = releaseData.find(release => | ||
| [status].flat().includes(release.status) | ||
| ); | ||
| let matchingRelease: NodeRelease | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could we do a folllo-up PR that doesn't do for and uses proper built-ins to match the repo convention style? cc @nodejs/nodejs-website
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure there is a built-in that can do what this is doing? No array methods have a break equivalent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean what we were doing before, Using array.find()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No? The old logic was iterating over release data so you can do a find to early return a match from it. The new logic iterates over status but early returns a value from release data, which I don't believe can be done cleanly with array methods?
| const releaseData = await provideReleaseData(); | ||
|
|
||
| const matchingRelease = releaseData.find(release => | ||
| [status].flat().includes(release.status) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original code would have worked fine, there was no need to refactor this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No? If there was a Maintenance LTS release in the array before an Active LTS release, the old logic would have picked the Maintenance LTS release. The new logic ensures we've looked at the whole array for an Active LTS release before switching to a Maintenance LTS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, that was an oversight. But I'd still wage over not using for statements within a React component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the context of this fix, I'd prefer for robust logic over using newer language syntax, a for loop works perfectly fine and really is doing nothing fundamentally different.
@targos - agree! Attendees of Collab Summit talked about this during - openjs-foundation/summit#469 - so hopefully in the nearish future we will introduce more clarity for users and simplicity for the website |
Description
There is no Active LTS release currently, just Current + Maintenance LTS releases, causing the main download page to render no content as it cannot find an Active LTS release. This updates the logic to allow an array of release statues to be passed in, with the provider trying to find a release with a matching status in the order they're provided in (e.g. it'll pick an Active LTS release even if it is after a Maintenance LTS release).
Validation
/en/downloadand/en/download/currentload.Related Issues
Resolves #8248
Check List
pnpm formatto ensure the code follows the style guide.pnpm testto check if all tests are passing.pnpm buildto check if the website builds without errors.