-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
fix: windows download incorrectly selects 32bit on 64bit machine #5025
Conversation
Signed-off-by: Steven <[email protected]>
I appreciate the PR, but we're on a code-freeze right now, not to mention all the current "javascript/jquery" code is going to be trashed, as we transition to the codebase from nodejs.dev. Would you mind opening an issue instead of a PR? So we can work on that when we start migrating the layouts? Thank you! |
I created issue https://github.com/nodejs/nodejs.dev/issues/3162 I also created PR nodejs/nodejs.dev#3163 |
Closing this, as the error is on the |
@nschonni The |
I created #5028 so you don't lose track of the However, I suggest you reopen my PR here since it is still relevant. |
No, the download URL comes from .org for both, but only https://nodejs.dev/en/ has this problem, not https://nodejs.org/en/ |
@nschonni Both have the same issue. Did you try it? Here's a screenshot with proof: |
It's possible something in the Insider build is broken, I can reproduce your issue on PS: The solution isn't to wipe out the architecture detection and always serve x64 |
Could be. Or it could point to changes coming in the future where the user agent no longer includes that information.
How about flipping the |
Definitely possible, but could also just a be a regression in a particular build. Here is the Edge user agent for Win 11 Edge
If you can find a way to do that, but I think only 64 had indications in the user agent, so that's why it is done this originally. I think most of the actual x86 windows versions are approaching EOL, so there may be value in visiting the approach as part of the redesign |
I investigated some more and found out Windows 11 is only 64 bit, there is no 32 bit version. Furthermore, there is no way to detect Windows 11 based on the user agent string.
https://www.whatismybrowser.com/guides/the-latest-user-agent/windows So then I found the official microsoft docs which say to use client hints or this JS script: navigator.userAgentData.getHighEntropyValues(["platformVersion"])
.then(ua => {
if (navigator.userAgentData.platform === "Windows") {
const majorPlatformVersion = parseInt(ua.platformVersion.split('.')[0]);
if (majorPlatformVersion >= 13) {
console.log("Windows 11 or later");
}
}
}); https://learn.microsoft.com/en-us/microsoft-edge/web-platform/how-to-detect-win11 I confirmed that this works on the insiders windows 11 build because But then I looked at MDN and saw this can be simplified even further to check for bitness. navigator.userAgentData.getHighEntropyValues(["bitness"])
.then(ua => {
console.log(ua.bitness) // "64"
}); https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData/getHighEntropyValues I think adding that script should solve the problem since it works on my build of windows 11 😄 Thoughts? |
That might make sense, but I'd suggest keeping the existing checks, and adding as the other |
I wanted to mention that UA's are being sunset (frozen) (through phasing). It will be tough to predict future OS's User-Agents in the future, as browsers will stop updating them. This is already reflected in Windows 11 by giving less information. |
@nschonni @ovflowd I pushed some changes to this branch to use the new API. Can we reopen this PR? (function () {
'use strict';
if (navigator.userAgentData && navigator.userAgentData.getHighEntropyValues) {
navigator.userAgentData
.getHighEntropyValues(['bitness'])
.then(function (ua) {
initDownloadHyperlink(ua.bitness);
})
.catch(function () {
// Ignore errors since not every browser supports this API
});
} else {
initDownloadHyperlink('unknown');
}
})(); |
I'm not sure how adopted this API is. What is the caniuse.com of this API? Anyways, I would highly recommend not making PRs to nodejs.org, as this will all go to waste. This main.js is going to be discarded very soon, so I recommend a PR against nodejs.dev to improve its detection mechanism there :) |
I did create one here nodejs/nodejs.dev#3163 |
Does that PR contain similar changes? (Leveraging the new API?) |
@ovflowd Yep, both PRs are very similar using the same |
@nschonni @ovflowd @shanpriyan Anything else we need to land this? |
@styfle could you rebase your PR so we can get this merged? |
@styfle : The file is totally changed with the new tech for Nodejs.org. So yours is useless and I've closed your change and re-open a new PR for you. Any suggestions welcomed! |
I just installed Windows 11 64 bit and opened Edge to install Node.js and it incorrectly installed the 32 bit version.
User Agent:
Also
navigator.cpuClass
is undefined so we need a new way to detect the the bitness.