-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replace Node.js REPL with plain vm context for script usage MON…
…GOSH-1720 (#1849) - Allow running `MongoshNodeRepl` instances either based on: - The existing mechanism for running code, which is spinning up a Node.js REPL and using it to evaluate code; or - A more lightweight mechanism that only creates a `vm` context and then run code using that context directly. - Introduce a new command-line switch, `--jsContext`, that can be used to explicitly select the desired behavior, with possible values of `repl`, `plain-vm` and `auto`. The default behavior is to switch depending on whether the CLI will enter interactive mode or not. Running in `plain-vm` mode will significantly improve runtime performance (a 6× reduction of script run time in local testing), coming from the removal of async context tracking that the REPL uses to identify async operations which were originally spawned from the REPL instance in question. This lack of async context tracking comes with some implications, in particular asynchronously thrown errors (in the Node.js sense, e.g. `setImmediate(() => { throw ... })`) will lead to slightly different behavior (e.g. different error code and error output). That is probably acceptable breakage in this context.
- Loading branch information
Showing
12 changed files
with
606 additions
and
299 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.