Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Dec 30, 2025

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

@roomote
Copy link
Contributor Author

roomote bot commented Dec 30, 2025

Rooviewer Clock   See task on Roo Cloud

Review complete. Found 1 issue that needs to be addressed before this PR can be merged.

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

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

standalone: false,
onLine: true,
};
globalThis.navigator = globalThis.navigator || navigatorStub;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The || operator will preserve the existing navigator if it exists. In Node.js 22+, navigator is already a global object, so globalThis.navigator || navigatorStub evaluates to the existing navigator rather than the stub. This means the shim won't actually be applied in the exact environment this PR targets. The fix should unconditionally replace navigator with the stub:

Suggested change
globalThis.navigator = globalThis.navigator || navigatorStub;
globalThis.navigator = navigatorStub;

Fix it with Roo Code or mention @roomote and request a fix.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels.

Projects

Status: Triage

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)

3 participants