Skip to content

Commit d7f9ceb

Browse files
committed
fix(compass-schema): limit complexity and toast for errors
1 parent 16724bf commit d7f9ceb

File tree

11 files changed

+233
-1078
lines changed

11 files changed

+233
-1078
lines changed

package-lock.json

Lines changed: 185 additions & 1025 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/compass-aggregations/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"mongodb-instance-model": "^12.26.2",
9292
"mongodb-ns": "^2.4.2",
9393
"mongodb-query-parser": "^4.3.0",
94-
"mongodb-schema": "^12.3.2",
94+
"mongodb-schema": "^12.4.0",
9595
"prop-types": "^15.7.2",
9696
"re-resizable": "^6.9.0",
9797
"react": "^17.0.2",

packages/compass-field-store/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"@mongodb-js/compass-logging": "^1.6.2",
7474
"hadron-app-registry": "^9.4.2",
7575
"lodash": "^4.17.21",
76-
"mongodb-schema": "^12.3.2",
76+
"mongodb-schema": "^12.4.0",
7777
"react": "^17.0.2",
7878
"react-redux": "^8.1.3",
7979
"redux": "^4.2.1",

packages/compass-generative-ai/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"compass-preferences-model": "^2.33.2",
6363
"hadron-app-registry": "^9.4.2",
6464
"mongodb": "^6.12.0",
65-
"mongodb-schema": "^12.3.2",
65+
"mongodb-schema": "^12.4.0",
6666
"react": "^17.0.2",
6767
"react-redux": "^8.1.3",
6868
"redux": "^4.2.1",

packages/compass-import-export/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"mongodb-data-service": "^22.25.2",
6969
"mongodb-ns": "^2.4.2",
7070
"mongodb-query-parser": "^4.3.0",
71-
"mongodb-schema": "^12.3.2",
71+
"mongodb-schema": "^12.4.0",
7272
"papaparse": "^5.3.2",
7373
"react": "^17.0.2",
7474
"react-redux": "^8.1.3",

packages/compass-query-bar/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"mongodb-ns": "^2.4.2",
8888
"mongodb-query-parser": "^4.3.0",
8989
"mongodb-query-util": "^2.4.2",
90-
"mongodb-schema": "^12.3.2",
90+
"mongodb-schema": "^12.4.0",
9191
"react": "^17.0.2",
9292
"react-redux": "^8.1.3",
9393
"redux": "^4.2.1",

packages/compass-schema/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
"lodash": "^4.17.21",
9393
"mongodb": "^6.12.0",
9494
"mongodb-query-util": "^2.4.2",
95-
"mongodb-schema": "^12.3.2",
95+
"mongodb-schema": "^12.4.0",
9696
"numeral": "^1.5.6",
9797
"prop-types": "^15.7.2",
9898
"react": "^17.0.2",

packages/compass-schema/src/components/schema-toolbar/schema-toolbar.tsx

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ import {
1111
} from '@mongodb-js/compass-components';
1212
import { usePreference } from 'compass-preferences-model/provider';
1313
import type { AnalysisState } from '../../constants/analysis-states';
14-
import {
15-
ANALYSIS_STATE_ERROR,
16-
ANALYSIS_STATE_TIMEOUT,
17-
ANALYSIS_STATE_COMPLETE,
18-
} from '../../constants/analysis-states';
14+
import { ANALYSIS_STATE_COMPLETE } from '../../constants/analysis-states';
1915
import { QueryBar } from '@mongodb-js/compass-query-bar';
2016

2117
const schemaToolbarStyles = css({
@@ -47,9 +43,6 @@ const schemaToolbarActionBarRightStyles = css({
4743
paddingLeft: spacing[2],
4844
});
4945

50-
const ERROR_WARNING = 'An error occurred during schema analysis';
51-
const INCREASE_MAX_TIME_MS_HINT_MESSAGE =
52-
'Operation exceeded time limit. Please try increasing the maxTimeMS for the query in the filter options.';
5346
const OUTDATED_WARNING_MESSAGE =
5447
'The schema content is outdated and no longer in sync' +
5548
' with the documents view. Press "Analyze" again to see the schema for the' +
@@ -130,15 +123,6 @@ const SchemaToolbar: React.FunctionComponent<SchemaToolbarProps> = ({
130123
</div>
131124
</div>
132125
)}
133-
{analysisState === ANALYSIS_STATE_ERROR && (
134-
<ErrorSummary
135-
data-testid="schema-toolbar-error-message"
136-
errors={[`${ERROR_WARNING}: ${errorMessage}`]}
137-
/>
138-
)}
139-
{analysisState === ANALYSIS_STATE_TIMEOUT && (
140-
<WarningSummary warnings={[INCREASE_MAX_TIME_MS_HINT_MESSAGE]} />
141-
)}
142126
{analysisState === ANALYSIS_STATE_COMPLETE && isOutdated && (
143127
<WarningSummary warnings={[OUTDATED_WARNING_MESSAGE]} />
144128
)}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
export const ANALYSIS_STATE_INITIAL = 'initial';
22
export const ANALYSIS_STATE_ANALYZING = 'analyzing';
3-
export const ANALYSIS_STATE_ERROR = 'error';
43
export const ANALYSIS_STATE_COMPLETE = 'complete';
5-
export const ANALYSIS_STATE_TIMEOUT = 'timeout';
64

75
export type AnalysisState =
86
| typeof ANALYSIS_STATE_INITIAL
97
| typeof ANALYSIS_STATE_ANALYZING
10-
| typeof ANALYSIS_STATE_ERROR
11-
| typeof ANALYSIS_STATE_COMPLETE
12-
| typeof ANALYSIS_STATE_TIMEOUT;
8+
| typeof ANALYSIS_STATE_COMPLETE;

packages/compass-schema/src/modules/schema-analysis.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ function promoteMongoErrorCode(err?: Error & { code?: unknown }) {
1919
return new Error('Unknown error');
2020
}
2121

22+
console.log({ name: err.name, code: err.code });
23+
2224
if (err.name === 'MongoError' && err.code !== undefined) {
2325
err.code = JSON.parse(JSON.stringify(err.code));
2426
}
@@ -59,6 +61,8 @@ export const analyzeSchema = async (
5961
);
6062
const schemaAccessor = await analyzeDocuments(docs, {
6163
signal: abortSignal,
64+
storedValuesLengthLimit: 100,
65+
distinctFieldsAbortThreshold: 1000,
6266
});
6367
log.info(mongoLogId(1001000090), 'Schema', 'Schema analysis completed', {
6468
ns,
@@ -69,6 +73,7 @@ export const analyzeSchema = async (
6973
ns,
7074
error: err.message,
7175
});
76+
console.log('FAILED', err);
7277
if (dataService.isCancelError(err)) {
7378
debug('caught background operation terminated error', err);
7479
return;

0 commit comments

Comments
 (0)