Skip to content

fix: fix the incorrect architecture detection in PlatformDropdown for Cloudflare builds#8839

Merged
dario-piotrowicz merged 4 commits intonodejs:mainfrom
dario-piotrowicz:dario/platform-dropdown-architecture-cloudflare-fix
Apr 23, 2026
Merged

fix: fix the incorrect architecture detection in PlatformDropdown for Cloudflare builds#8839
dario-piotrowicz merged 4 commits intonodejs:mainfrom
dario-piotrowicz:dario/platform-dropdown-architecture-cloudflare-fix

Conversation

@dario-piotrowicz
Copy link
Copy Markdown
Member

@dario-piotrowicz dario-piotrowicz commented Apr 23, 2026

Description

OS detection and architecture detection can arrive in the same React render cycle. When that happens, both useEffect hooks in PlatformDropdown fire at the same time, the first one correctly dispatches setPlatform('arm64'), but the second one reads release.platform from its stale closure (still 'x64') and immediately calls setPlatform('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 dev and pnpm cloudflare:preview and verified that now both correctly detect the correct architecture

Related Issues

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run pnpm format to ensure the code follows the style guide.
  • I have run pnpm test to check if all tests are passing.
  • I have run pnpm build to check if the website builds without errors.
  • I've covered new added functionality with unit tests if necessary.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nodejs-org Ready Ready Preview Apr 23, 2026 3:13pm

Request Review

@github-actions
Copy link
Copy Markdown
Contributor

👋 Codeowner Review Request

The 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
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.87%. Comparing base (524e64b) to head (a095200).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

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.
📢 Have feedback on the report? Share it here.

@dario-piotrowicz dario-piotrowicz force-pushed the dario/platform-dropdown-architecture-cloudflare-fix branch from 72babb2 to 8b78c42 Compare April 23, 2026 11:29
@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review April 23, 2026 11:34
@dario-piotrowicz dario-piotrowicz requested a review from a team as a code owner April 23, 2026 11:34
Copilot AI review requested due to automatic review settings April 23, 2026 11:34
@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 23, 2026

PR Summary

Medium Risk
Touches React state/effect ordering in the downloads flow; subtle dependency changes could cause platform selection to update unexpectedly across OS/version changes, but scope is limited to the platform dropdown.

Overview
Fixes a race where simultaneous OS and architecture detection could cause PlatformDropdown to overwrite the correct auto-detected platform with a stale value.

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 release.platform to avoid stale-closure overrides.

Reviewed by Cursor Bugbot for commit a095200. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 currentPlatform as the starting platform and remove release.platform from its dependency list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/site/components/Downloads/Release/PlatformDropdown.tsx
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread apps/site/components/Downloads/Release/PlatformDropdown.tsx Outdated
Copy link
Copy Markdown
Member

@ovflowd ovflowd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to wrap my head around on why this would be needed 🤔

Why it works in Vercel but it breaks in Cloudflare 😅

Comment thread apps/site/components/Downloads/Release/PlatformDropdown.tsx
Comment thread apps/site/components/Downloads/Release/PlatformDropdown.tsx Outdated
Comment thread apps/site/components/Downloads/Release/PlatformDropdown.tsx Outdated
Comment thread apps/site/components/Downloads/Release/PlatformDropdown.tsx
@dario-piotrowicz
Copy link
Copy Markdown
Member Author

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? 🤷

Copy link
Copy Markdown
Member

@ovflowd ovflowd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM!

@dario-piotrowicz dario-piotrowicz added this pull request to the merge queue Apr 23, 2026
Merged via the queue into nodejs:main with commit 97e28c5 Apr 23, 2026
14 checks passed
@dario-piotrowicz dario-piotrowicz deleted the dario/platform-dropdown-architecture-cloudflare-fix branch April 23, 2026 16:45
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.

4 participants