Skip to content

Conversation

@PavelSafronov
Copy link
Contributor

Description

Summary of Changes

The driver will explicitly import node:process instead of relying on the global.
eslint rule no-restricted-globals is also enabled.

What is the motivation for this change?

This helps us reduce our runtime dependencies, as part of https://jira.mongodb.org/browse/NODE-6601

Double check the following

  • Lint is passing (npm run check:lint)
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@addaleax
Copy link
Contributor

addaleax commented Dec 9, 2025

Are you sure you want this? How does it reduce runtime dependencies?

globals are generally much easier to polyfill (/existing polyfills already handle them), so this seems counterintuitive.

The vast majority of these are accesses to process.nextTick() or process.env; I still think you'll want queueMicrotask() as a replacement for the former, and the environment I'd consider passing to the MongoClient as an option (with process.env as the default value)

@PavelSafronov
Copy link
Contributor Author

Are you sure you want this?

This is one of the intentions of this doc, to remove the dependence on a global process: Design: Remove dependence on runtime specific APIs.

How does it reduce runtime dependencies?

This change itself doesn't, but it allows bundlers to supplant the variable consistently.

The vast majority of these are accesses to process.nextTick() or process.env; I still think you'll want queueMicrotask() as a replacement for the former, and the environment I'd consider passing to the MongoClient as an option (with process.env as the default value)

The queueMicrotask change will go in first, then I'll update this PR and mark it ready. We will eventually allow a way for users to pass this information to the client, but that is part of the later milestones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants