Skip to content

Conversation

nbbeeken
Copy link
Collaborator

Description

npm start++

There is now a script responsible for multi-process launching to enable and encourage mulitplatform testing of compass and DE changes. npm start will still launch compass as per usual.

New Commands:

npm start desktop sync sandbox

Provide each one of the subcommands optionally to combine launching each environment to start testing changes in parallel.

Note that the sync command still requires use of a redirector / redwood extension in your browser.

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

In the effort of DE and Compass unification hopefully this change will make verifying in both environements easy and commonplace to squash inconsistency early on in development.

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

Comment on lines +46 to +57
const halfRamMb = Math.min(
Math.floor(os.totalmem() / 2 / 1024 / 1024),
16384
);
// Merge with existing NODE_OPTIONS if present
const existingNodeOptions = process.env.NODE_OPTIONS ?? '';
const mergedNodeOptions = [
`--max_old_space_size=${halfRamMb}`,
existingNodeOptions,
]
.filter(Boolean)
.join(' ');
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When running sync, webpack OOMs after a while of use, this seems to make it last much longer. An alternative is we can reboot.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we can do something about this, I'm like 99% sure it's source map generation in mms build that causes this. Maybe we can try switching it off on mms side, compass-web will also have source maps and presumably if you're running this script, that's the main source maps you care about

Comment on lines +36 to +38
for (const arg of args) {
if (validTargets.includes(arg as keyof typeof targets)) {
// Switch to new target
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Possibly overboard, I support passing arguments to each target but I also don't know of any use cases for that, just figured there probably are some.

Comment on lines +38 to +41
child_process.execFileSync('pnpm', ['install'], {
cwd: process.env.MMS_HOME,
stdio: 'inherit',
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we either make this skippable or make it ignore strict engine requirement in mms? I usually keep nodejs version on the same version as electron for compass and it rarely matches what mms has

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I made it skippable, I have tried to run MMS on different Node's before, if its working for you then that's great I've hit so many silly failures related to the strictness before 🤷🏻

Comment on lines 42 to 45
child_process.execFileSync('pnpm', ['run', 'init'], {
cwd: process.env.MMS_HOME,
stdio: 'inherit',
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't need init, it's doing the same thing that start will do right after

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yea I always thought the output looks similar but pressing enter on the command in my terminal history was easier than looking into why 🤦🏻 lol thank you!

Comment on lines +29 to +30
desktop: { enabled: false, args: [] as string[] },
sandbox: { enabled: false, args: [] as string[] },
Copy link
Collaborator

Choose a reason for hiding this comment

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

desktop and sandbox currently have ports in common, so you can't run then in parallel, you might want to adjust that

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

just made sandbox something you have to run alone because of the way things are shared, I think desktop & sync are more likely to be used in parallel? at least by our team. But happy to dig deeper if you have a better idea of what needs to be changed.

Like I changed the compass-web dev server port but then something else is using that config because I get a port reuse error 🤔


const paddedName = targetName.padEnd(8);
console.log(`start | ${spawnArgs[0]} ${spawnArgs[1].join(' ')}`);
const subProcess = child_process.spawn(...spawnArgs);
Copy link
Collaborator

Choose a reason for hiding this comment

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

You need to pipe stdin also. Desktop command in particular has support for extra commands to restart the process / pass extra args:

desktop  | <i> [webpack-plugin-start-electron] Starting electron application
desktop  | <i> [webpack-plugin-start-electron] - Ctrl+R to restart the main process
desktop  | <i> [webpack-plugin-start-electron] - Ctrl+A to restart the main process with extra arguments

And none of it is working at the moment

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

should be working now 🎉

@nbbeeken nbbeeken marked this pull request as ready for review September 19, 2025 20:55
@nbbeeken nbbeeken requested a review from a team as a code owner September 19, 2025 20:55
@nbbeeken nbbeeken requested review from Anemy and Copilot and removed request for Anemy September 19, 2025 20:55
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new npm start command that allows launching multiple Compass environments (desktop, sandbox, sync) in parallel to streamline testing across different platforms.

  • New multi-process launcher script that can start desktop, sandbox, and sync environments together
  • Enhanced sync script converted from JS to MJS with improved MMS dev server management
  • Updated package.json configurations to support the new start command

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
scripts/start.mts New multi-process launcher script handling argument parsing and subprocess management
scripts/start.md Help documentation for the new start command
packages/compass-web/scripts/sync-dist-to-mms.mjs Converted sync script from JS to MJS with enhanced MMS server handling
packages/compass-web/scripts/sync-dist-to-mms.js Removed old JS version of sync script
packages/compass-web/package.json Updated sync command to use new MJS script
packages/compass-web/.eslintrc.js Added ESLint configuration for MJS files
package.json Updated root start command to use new launcher script

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@nbbeeken nbbeeken requested a review from gribnoysup September 22, 2025 17:10
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