MCPcopy
hub / github.com/mongodb/node-mongodb-native / abort

Method abort

src/gridfs/upload.ts:201–218  ·  view source on GitHub ↗

* Places this write stream into an aborted state (all future writes fail) * and deletes all chunks that have already been written.

()

Source from the content-addressed store, hash-verified

199 * and deletes all chunks that have already been written.
200 */
201 async abort(): Promise<void> {
202 if (this.state.streamEnd) {
203 // TODO(NODE-3485): Replace with MongoGridFSStreamClosed
204 throw new MongoAPIError('Cannot abort a stream that has already completed');
205 }
206
207 if (this.state.aborted) {
208 // TODO(NODE-3485): Replace with MongoGridFSStreamClosed
209 throw new MongoAPIError('Cannot call abort() on a stream twice');
210 }
211
212 this.state.aborted = true;
213 const remainingTimeMS = this.timeoutContext?.getRemainingTimeMSOrThrow(
214 `Upload timed out after ${this.timeoutContext?.timeoutMS}ms`
215 );
216
217 await this.chunks.deleteMany({ files_id: this.id }, { timeoutMS: remainingTimeMS });
218 }
219}
220
221function handleError(stream: GridFSBucketWriteStream, error: Error, callback: Callback): void {

Callers 15

jquery.jsFile · 0.45
utils.tsFile · 0.45
operations.tsFile · 0.45
constructorMethod · 0.45
clearMethod · 0.45
gridfs.test.tsFile · 0.45
testFunction · 0.45
testCursorFunction · 0.45
testFunction · 0.45

Calls 2

deleteManyMethod · 0.80

Tested by 5

constructorMethod · 0.36
clearMethod · 0.36
testFunction · 0.36
testCursorFunction · 0.36
testFunction · 0.36