Skip to content

Commit fee2cc7

Browse files
rmi22186claude
andcommitted
fix: guard against timer rescheduling after destroy
Add a `destroyed` flag to prevent prepareAndUpload from rescheduling a new timer via triggerUploadInterval if destroy() was called while an upload was in-flight. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 754c310 commit fee2cc7

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/batchUploader.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export class BatchUploader {
5050
private uploadIntervalTimerId: ReturnType<typeof setTimeout> | null = null;
5151
private exitHandler: (() => void) | null = null;
5252
private visibilityChangeHandler: (() => void) | null = null;
53+
private destroyed = false;
5354

5455
/**
5556
* Creates an instance of a BatchUploader
@@ -113,6 +114,8 @@ export class BatchUploader {
113114
* is re-initialized (e.g. between tests or on repeated init calls).
114115
*/
115116
public destroy(): void {
117+
this.destroyed = true;
118+
116119
if (this.uploadIntervalTimerId !== null) {
117120
clearTimeout(this.uploadIntervalTimerId);
118121
this.uploadIntervalTimerId = null;
@@ -476,7 +479,7 @@ export class BatchUploader {
476479
this.batchesQueuedForProcessing = [];
477480
}
478481

479-
if (triggerFuture) {
482+
if (triggerFuture && !this.destroyed) {
480483
this.triggerUploadInterval(triggerFuture, false);
481484
}
482485
}

0 commit comments

Comments
 (0)