Skip to content

Fix platform detection after Node.js 21#200935

Merged
bpasero merged 1 commit intomicrosoft:mainfrom
kkocdko:main
Dec 16, 2023
Merged

Fix platform detection after Node.js 21#200935
bpasero merged 1 commit intomicrosoft:mainfrom
kkocdko:main

Conversation

@kkocdko
Copy link
Copy Markdown
Contributor

@kkocdko kkocdko commented Dec 15, 2023

Node.js 21 added navigator.userAgent, which breaks the previous detection.

Close #200934

Node.js 21 added `navigator.userAgent`, which breaks the previous detection.
@kkocdko
Copy link
Copy Markdown
Contributor Author

kkocdko commented Dec 15, 2023

The same problem happen in xterm.js, and is already fixed.

xtermjs/xterm.js#4850

xtermjs/xterm.js#4851

nodejs/node#47769 (comment)

_language = _locale;
_platformLocale = navigator.language;
}

Copy link
Copy Markdown
Contributor Author

@kkocdko kkocdko Dec 15, 2023

Choose a reason for hiding this comment

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

Only reorder two code block, without change the block content.

declare const navigator: INavigator;

// Web environment
if (typeof navigator === 'object' && !isElectronRenderer) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Previous detection expect that Node.js doesn't have navigator, now Node.js 21 had, with navigator.userAgent === 'Node.js/21' .

Copy link
Copy Markdown
Collaborator

@deepak1556 deepak1556 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

/cc @bpasero for another set of 👀

@deepak1556 deepak1556 assigned bpasero and unassigned deepak1556 Dec 15, 2023
@deepak1556 deepak1556 requested a review from bpasero December 15, 2023 18:53
@vscodenpa vscodenpa added this to the December / January 2024 milestone Dec 15, 2023
@bpasero bpasero enabled auto-merge (squash) December 16, 2023 10:02
@bpasero bpasero merged commit c52d8fb into microsoft:main Dec 16, 2023
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extension can't be install from market on ./scripts/code-server.sh with nodejs 21

5 participants