Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

fix: add navigator shim for Node.js 22+ compatibility in code-server - #10400

Closed
ghost wants to merge 2 commits into
mainfrom
fix/navigator-shim-nodejs22
Closed

fix: add navigator shim for Node.js 22+ compatibility in code-server#10400
ghost wants to merge 2 commits into
mainfrom
fix/navigator-shim-nodejs22

Conversation

@ghost

@ghost ghost commented Dec 30, 2025

Copy link
Copy Markdown

Related GitHub Issue

Closes: #10391

Description

This PR attempts to address Issue #10391 by adding a navigator shim in the esbuild configuration to fix the PendingMigrationError that occurs on code-server with Node.js 22+.

The Problem:
In Node.js 22+, navigator is now a global object. Several bundled dependencies (debug, axios, pdf-parse) check typeof navigator !== "undefined" and then try to access properties like navigator.userAgent. VS Code's extension host intercepts these accesses and throws PendingMigrationError to help extensions migrate.

The Solution:
Added a JavaScript banner in the esbuild configuration that creates a safe navigator stub before any bundled code runs. The stub provides empty/default values for commonly accessed navigator properties:

  • userAgent, platform, appName, appVersion, product: empty strings
  • userLanguage: undefined
  • languages: empty array
  • hardwareConcurrency: 1
  • standalone: false
  • onLine: true

This shim is applied to both the extension and worker bundles via the shared buildOptions configuration.

Test Procedure

  1. The lint checks pass successfully
  2. JavaScript syntax validation passes with node --check src/esbuild.mjs
  3. Full testing requires code-server v4.105.0 on RHEL 9.6 environment (as described in the issue)
  4. Manual testing by the issue reporter would validate the fix

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

Additional Notes

@ghost

ghost commented Dec 30, 2025

Copy link
Copy Markdown
Author

Rooviewer Clock   See task on Roo Cloud

Review complete. All previously identified issues have been addressed.

  • The || logic on line 36 prevents the navigator stub from being applied in Node.js 22+ where navigator already exists
Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Comment thread src/esbuild.mjs Outdated
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 30, 2025
Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>
@hannesrudolph hannesrudolph moved this from Triage to PR [Draft / In Progress] in Roo Code Roadmap Jan 8, 2026
@hannesrudolph hannesrudolph added PR - Draft / In Progress and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jan 8, 2026
@github-project-automation github-project-automation Bot moved this from PR [Draft / In Progress] to Done in Roo Code Roadmap Jan 30, 2026
@github-project-automation github-project-automation Bot moved this from New to Done in Roo Code Roadmap Jan 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] PendingMigrationError: navigator is now a global in nodejs on code-server (RHEL 9.6, Offline Environment)

2 participants