Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion configs/eslint-config-compass/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const tempNewEslintRulesDisabled = {
'react-hooks/static-components': 'off',
'react-hooks/purity': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/await-thenable': 'off',
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ describe('PipelinePreviewManager', function () {
const dataService = mockDataService({ data: [] });
const previewManager = new PipelinePreviewManager(dataService, preferences);

const result = await Promise.allSettled([
previewManager.getPreviewForStage(0, 'test.test', []),
previewManager.cancelPreviewForStage(0),
]);

expect(result[0]).to.have.property('status', 'rejected');
expect(result[0]).to.have.nested.property('reason.name', 'AbortError');
try {
const result = previewManager.getPreviewForStage(0, 'test.test', []);
previewManager.cancelPreviewForStage(0);
await result;
expect.fail('Expected promise to reject');
} catch (err) {
expect(err).to.have.property('name', 'AbortError');
}
});

it('should debounce aggregation calls for the same stage', async function () {
Expand Down Expand Up @@ -108,7 +109,7 @@ describe('PipelinePreviewManager', function () {
previewManager.getPreviewForStage(2, 'test.test', []),
previewManager.getPreviewForStage(3, 'test.test', []),
previewManager.getPreviewForStage(4, 'test.test', []),
previewManager.clearQueue(1),
Promise.resolve(previewManager.clearQueue(1)),
]);

// Only pipeline for stage 0 was executed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2100,10 +2100,9 @@ const cleanupConnection = (
const connectionAttempt = ConnectionAttemptForConnection.get(connectionId);
const dataService = DataServiceForConnection.get(connectionId);

void Promise.all([
connectionAttempt?.cancelConnectionAttempt(),
dataService?.disconnect(),
]).then(
connectionAttempt?.cancelConnectionAttempt();

void dataService?.disconnect().then(
() => {
debug('connection closed', connectionId);
},
Expand Down Expand Up @@ -2219,7 +2218,10 @@ export const removeAllRecentConnections = (): ConnectionsThunkAction<
toRemove.map((connection) => {
dispatch(cleanupConnection(connection.info.id));
track('Connection Removed', {}, connection.info);
return connectionStorage.delete?.({ id: connection.info.id });
return (
connectionStorage.delete?.({ id: connection.info.id }) ??
Promise.resolve()
);
Comment on lines +2221 to +2224
Copy link
Collaborator

Choose a reason for hiding this comment

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

(not asking for a change here) This is where I feel like an async (keyword) function is more appropriate than substituting a Promise.resolve. Plus return-await is a rule we employed in the driver because when you don't do that you remove functions from async stack traces.

return await connectionStorage.delete?.({ id: connection.info.id });

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This does read better, let me see if switching to this will scream at me because I'm awaiting something that is maybe non-thenable (also makes sense in global-fixtures code I guess)

})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ export async function mochaGlobalTeardown() {
debug('Cleaning up after the tests ...');
await Promise.allSettled(
cleanupFns.map((fn) => {
return fn();
// We get a mix of sync and non-sync functions here. Awaiting even the
// sync ones just makes the logic simpler
return Promise.resolve(fn());
})
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ describe('atlasOptInReducer', function () {
.dispatch(optIntoGenAIWithModalPrompt({ isCloudOptIn: true }))
.catch(() => {});

await Promise.all([
store.dispatch(optIn()),
store.dispatch(cancelOptIn()),
]);
const promise = store.dispatch(optIn());
store.dispatch(cancelOptIn());
await promise;

expect(store.getState().optIn).to.have.nested.property(
'state',
'canceled'
Expand Down
4 changes: 2 additions & 2 deletions packages/compass-indexes/src/modules/regular-indexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ const fetchIndexes = (
dataService.indexes(namespace),
shouldFetchRollingIndexes
? rollingIndexesService.listRollingIndexes(namespace)
: undefined,
] as [Promise<IndexDefinition[]>, Promise<AtlasIndexStats[]> | undefined];
: Promise.resolve(undefined),
] as const;
const [indexes, rollingIndexes] = await Promise.all(promises);
const indexesBefore = pickCollectionStatFields(getState());
dispatch(fetchIndexesSucceeded(indexes, rollingIndexes));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ export const fetchItems = (): SavedQueryAggregationThunkAction<
{ pipelineStorage, queryStorage }
): Promise<void> => {
const payload = await Promise.allSettled([
(await pipelineStorage?.loadAll())?.map(mapAggregationToItem) ?? [],
(await queryStorage?.loadAll())?.map(mapQueryToItem) ?? [],
pipelineStorage?.loadAll().then((items) => {
return items.map(mapAggregationToItem);
}) ?? Promise.resolve([]),
queryStorage?.loadAll().then((items) => {
return items.map(mapQueryToItem);
}) ?? Promise.resolve([]),
]);
dispatch({
type: ActionTypes.ITEMS_FETCHED,
Expand Down
Loading