<!-- llms-explorer concept facts · https://llms-explorer.com/tree/pinned-compass-stage-preview-cancellation-before-aggregate-dispatch/ · pack 2026-11-02 · ~1365 tokens -->

# Pinned Compass stage-preview cancellation before aggregate dispatch

> Source-anchored research for Pinned Compass stage-preview cancellation before aggregate dispatch. Run status: COMPLETED.

Parent: [MongoDB Compass](https://llms-explorer.com/tree/mongodb-compass/) · 1 facets · 7 facts · page: https://llms-explorer.com/tree/pinned-compass-stage-preview-cancellation-before-aggregate-dispatch/

## Facts and statements

- In the cited pinned implementation, getPreviewForStage aborts the controller already queued for its stage index, creates a replacement AbortController, and stores it before awaiting raceWithAbort over Promise.all([getPipeline(), getPreviewOptions()]). The abort signal can therefore reject this wait while either input is unresolved. (high confidence) — [source](https://raw.githubusercontent.com/mongodb-js/compass/1292483d33fe97513c41e0e67020e4438deb3f69/packages/compass-aggregations/src/modules/pipeline-builder/pipeline-preview-manager.ts) · [also](https://raw.githubusercontent.com/mongodb-js/compass/1292483d33fe97513c41e0e67020e4438deb3f69/packages/compass-utils/src/cancellable-promise.ts) · [also](https://raw.githubusercontent.com/mongodb-js/compass/1292483d33fe97513c41e0e67020e4438deb3f69/packages/compass-aggregations/src/modules/pipeline-builder/pipeline-preview-manager.spec.ts)
- cancelPreviewForStage aborts the queued controller, deletes the remembered pipeline, and returns the queue deletion result. The mocked pending-pipeline and pending-options fixtures assert that cancellation returns true, the request rejects with AbortError, and dataService.aggregate is never called after the pending input resolves. (medium confidence) — [source](https://raw.githubusercontent.com/mongodb-js/compass/1292483d33fe97513c41e0e67020e4438deb3f69/packages/compass-aggregations/src/modules/pipeline-builder/pipeline-preview-manager.ts) · [also](https://raw.githubusercontent.com/mongodb-js/compass/1292483d33fe97513c41e0e67020e4438deb3f69/packages/compass-aggregations/src/modules/pipeline-builder/pipeline-preview-manager.spec.ts)
- clearQueue aborts and removes queued requests at or above its starting index and deletes their remembered pipelines. Its pending-parsing fixture calls clearQueue before resolving the pipeline and asserts that dataService.aggregate is never called. (medium confidence) — [source](https://raw.githubusercontent.com/mongodb-js/compass/1292483d33fe97513c41e0e67020e4438deb3f69/packages/compass-aggregations/src/modules/pipeline-builder/pipeline-preview-manager.ts) · [also](https://raw.githubusercontent.com/mongodb-js/compass/1292483d33fe97513c41e0e67020e4438deb3f69/packages/compass-aggregations/src/modules/pipeline-builder/pipeline-preview-manager.spec.ts)
- A newer request for the same stage aborts its predecessor before awaiting its own inputs. The mocked older-request fixture resolves the older pipeline after creating the newer request and asserts an AbortError for the older request, fulfillment for the newer request, one aggregate call, and a remembered pipeline equal to the newer pipeline. (high confidence) — [source](https://raw.githubusercontent.com/mongodb-js/compass/1292483d33fe97513c41e0e67020e4438deb3f69/packages/compass-aggregations/src/modules/pipeline-builder/pipeline-preview-manager.ts) · [also](https://raw.githubusercontent.com/mongodb-js/compass/1292483d33fe97513c41e0e67020e4438deb3f69/packages/compass-aggregations/src/modules/pipeline-builder/pipeline-preview-manager.spec.ts)
- After input resolution, the manager waits with cancellableWait unless force is true. It records the pipeline and calls aggregatePipeline afterward, passing the same controller signal. The helper implements cancellableWait using raceWithAbort around a timeout promise. Thus force skips the debounce branch but does not remove the earlier input-resolution abort race. (high confidence) — [source](https://raw.githubusercontent.com/mongodb-js/compass/1292483d33fe97513c41e0e67020e4438deb3f69/packages/compass-aggregations/src/modules/pipeline-builder/pipeline-preview-manager.ts) · [also](https://raw.githubusercontent.com/mongodb-js/compass/1292483d33fe97513c41e0e67020e4438deb3f69/packages/compass-utils/src/cancellable-promise.ts)
- For this preview path, raceWithAbort rejects an already-aborted signal or races the supplied promise against an abort-listener rejection, then removes the listener in finally. It does not pass a cancellation callback to getPipeline or getPreviewOptions; rejecting the preview wait is not evidence that the underlying parser promises stop executing. (high confidence) — [source](https://raw.githubusercontent.com/mongodb-js/compass/1292483d33fe97513c41e0e67020e4438deb3f69/packages/compass-aggregations/src/modules/pipeline-builder/pipeline-preview-manager.ts) · [also](https://raw.githubusercontent.com/mongodb-js/compass/1292483d33fe97513c41e0e67020e4438deb3f69/packages/compass-utils/src/cancellable-promise.ts)
- The cited cancellation and supersession fixtures use mockDataService and assert promise outcomes, aggregate call counts, and remembered-pipeline equality. These are source assertions read for this research, not tests executed here; those assertions do not establish termination of an operation on a live MongoDB server. (low confidence) — [source](https://raw.githubusercontent.com/mongodb-js/compass/1292483d33fe97513c41e0e67020e4438deb3f69/packages/compass-aggregations/src/modules/pipeline-builder/pipeline-preview-manager.spec.ts)
