fix(cli-repl): account for Node.js main branch REPL changes#2690
Open
fix(cli-repl): account for Node.js main branch REPL changes#2690
Conversation
nodejs/node@a9da9ff recently introduced a number of changes to the Node.js REPL that break mongosh's e2e test suite. This is mostly our own fault, since we were previously monkey-patching the Node.js REPL in a way that wouldn't typically be considered supported. This change updates these patches for the new change. It also adds a small custom inspect function for the REPL instance, since otherwise now even small objects like Node.js timers could result in hundreds of lines of output being printed when fully inspected.
Contributor
There was a problem hiding this comment.
Pull request overview
Updates mongosh’s CLI REPL integration to accommodate recent upstream Node.js REPL internal changes that impacted mongosh e2e tests, and reduces excessive output caused by deep inspection of REPL-linked async state.
Changes:
- Add a custom
util.inspect.customhandler on the REPL server to prevent extremely verbose inspection output (e.g., from timers retaining async context). - Update the REPL eval monkey-patching to hook into Node’s newer
_handleErrorpath (in addition to existing domain-related handling).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/cli-repl/src/mongosh-repl.ts | Adds a custom inspect function to keep REPL-related inspection output compact under the new Node REPL async context behavior. |
| packages/cli-repl/src/async-repl.ts | Adjusts synchronous-error interception to patch repl._handleError for newer Node.js REPL internals. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
nodejs/node@a9da9ff recently introduced a number of changes to the Node.js REPL that break mongosh's e2e test suite. This is mostly our own fault, since we were previously monkey-patching the Node.js REPL in a way that wouldn't typically be considered supported.
This change updates these patches for the new change. It also adds a small custom inspect function for the REPL instance, since otherwise now even small objects like Node.js timers could result in hundreds of lines of output being printed when fully inspected.