fix: fix the incorrect architecture detection in PlatformDropdown for Cloudflare builds#8839
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
👋 Codeowner Review RequestThe following codeowners have been identified for the changed files: Team reviewers: @nodejs/nodejs-website Please review the changes when you have a chance. Thank you! 🙏 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8839 +/- ##
==========================================
- Coverage 73.88% 73.87% -0.02%
==========================================
Files 105 105
Lines 8889 8883 -6
Branches 326 326
==========================================
- Hits 6568 6562 -6
Misses 2320 2320
Partials 1 1 ☔ View full report in Codecov by Sentry. |
… Cloudflare builds
72babb2 to
8b78c42
Compare
PR SummaryMedium Risk Overview The dropdown now computes the detected platform during render and reuses it across both effects, and it tracks whether the user manually selected a platform so OS/version updates don’t reset the user’s choice; the OS/version effect also no longer depends on Reviewed by Cursor Bugbot for commit a095200. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Pull request overview
Fixes a Cloudflare-specific race in PlatformDropdown where OS and architecture detection can resolve in the same React batch, causing the platform to be overwritten with a stale value.
Changes:
- Compute the detected platform during render (
currentPlatform) so both effects share the same value within a commit. - Update the architecture/bitness effect to use
currentPlatform. - Update the OS/version effect to use
currentPlatformas the starting platform and removerelease.platformfrom its dependency list.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8b78c42. Configure here.
ovflowd
left a comment
There was a problem hiding this comment.
I am trying to wrap my head around on why this would be needed 🤔
Why it works in Vercel but it breaks in Cloudflare 😅
yeah... I don't know... it is client side logic so this is pretty baffling... maybe on Cloudflare some assets gets served in parallel? 🤷 |

Description
OS detection and architecture detection can arrive in the same React render cycle. When that happens, both
useEffecthooks inPlatformDropdownfire at the same time, the first one correctly dispatchessetPlatform('arm64'), but the second one readsrelease.platformfrom its stale closure (still'x64') and immediately callssetPlatform('x64')overriding the correct value. On Vercel I believe this worked by accident of timing, as the two detections land in separate render cycles, for whatever reason that doesn't seem to be the case in Cloudflare.So the fix is to compute the platform during render and use it in both
useEffects, so that they share the same up-to-date value when they fire together.Validation
I've run the app locally via
pnpm devandpnpm cloudflare:previewand verified that now both correctly detect the correct architectureRelated Issues
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.