Skip to content

Conversation

nbbeeken
Copy link
Collaborator

Description

Using a preference I control whether or not to show the warning and prevent setting a higher maxTimeMS.

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

  • 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)

);

// Data Explorer limits for maxTimeMS (5 minutes = 300,000ms)
const WEB_MAX_TIME_MS_LIMIT = 300_000; // 5 minutes
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd suggest storing this in a single place + explaining why 5 minutes is the value we chose here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

agreed and done!

@nbbeeken nbbeeken marked this pull request as ready for review September 29, 2025 14:19
@nbbeeken nbbeeken requested a review from a team as a code owner September 29, 2025 14:19
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 maxTimeMS warning system for CompassWeb to prevent users from setting query timeouts longer than 5 minutes (300,000ms), which is the Data Explorer backend limit. The implementation uses a new preference showMaxTimeMSWarning that is enabled by default in the web environment.

  • Adds showMaxTimeMSWarning preference to control the warning behavior
  • Implements hard limit enforcement and validation for maxTimeMS fields
  • Adds tooltip warnings when users attempt to exceed the 5-minute limit

Reviewed Changes

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

Show a summary per file
File Description
packages/compass-web/src/entrypoint.tsx Enables the showMaxTimeMSWarning preference by default for CompassWeb
packages/compass-preferences-model/src/preferences-schema.tsx Defines the new showMaxTimeMSWarning preference with proper schema validation
packages/compass-query-bar/src/constants/query-option-definition.ts Adds WEB_MAX_TIME_MS_LIMIT constant and updates maxTimeMS input validation
packages/compass-query-bar/src/utils/query.ts Updates validation functions to enforce the 5-minute limit when warnings are enabled
packages/compass-query-bar/src/stores/query-bar-reducer.ts Passes showMaxTimeMSWarning preference to validation functions
packages/compass-query-bar/src/components/query-option.tsx Adds tooltip warning UI for maxTimeMS fields exceeding the limit
packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-options/pipeline-collation.tsx Applies the same maxTimeMS validation and warning to aggregation pipeline options

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

}
const fields = mapQueryToFormFields(
{ maxTimeMS: preferences.getPreferences().maxTimeMS },
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

there are two more instances of mapQueryToFormFields in this file and another in the option-editor.tsx, is it expected that those don't get the new param?

if (field === 'maxTimeMS') {
const maxTimeMS = Number(value);

// When warning is enabled, enforce hard limit
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment is needed because the name of the preference is not clear ;) Sounds like the switch is really to enforce or not enforce an upper bound to maxTimeMs - WEB_MAX_TIME_MS_LIMIT.
What do you think about having the upper bound as numeric optional preference, so that the constant IS the preference and it is only defined once?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ooo I like that, thanks for the idea 🫡

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

Successfully merging this pull request may close these issues.

3 participants