Skip to content

Fix platform detection after Node.js 21 - #200935

Merged
Benjamin Pasero (bpasero) merged 1 commit into
microsoft:mainfrom
kkocdko:main
Dec 16, 2023
Merged

Benjamin Pasero (bpasero) merged 1 commit into
microsoft:mainfrom
kkocdko:main

Conversation

@kkocdko

Copy link
Copy Markdown
Contributor

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

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;
}

@kkocdko kkocdko (kkocdko) Dec 15, 2023 •

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.

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

@deepak1556 Robo (deepak1556) left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, thanks!

/cc Benjamin Pasero (@bpasero) for another set of 👀

@bpasero
Benjamin Pasero (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