Skip to content

Commit

Permalink
chore: replace Promise.finally with two param .then
Browse files Browse the repository at this point in the history
  • Loading branch information
aabmass committed Aug 10, 2021
1 parent 3945af0 commit 9ba634e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ export abstract class CollectorExporterNodeBase<
.then(onSuccess, onError);

this._sendingPromises.push(promise);
promise.finally(() => {
const popPromise = () => {
const index = this._sendingPromises.indexOf(promise);
this._sendingPromises.splice(index, 1);
});
}
promise.then(popPromise, popPromise);
}

onInit(config: CollectorExporterConfigNode): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ export abstract class CollectorExporterNodeBase<
.then(onSuccess, onError);

this._sendingPromises.push(promise);
promise.finally(() => {
const popPromise = () => {
const index = this._sendingPromises.indexOf(promise);
this._sendingPromises.splice(index, 1);
});
}
promise.then(popPromise, popPromise);
}

override onInit(config: CollectorExporterNodeConfigBase): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ export abstract class CollectorExporterBrowserBase<
.then(onSuccess, onError);

this._sendingPromises.push(promise);
promise.finally(() => {
const popPromise = () => {
const index = this._sendingPromises.indexOf(promise);
this._sendingPromises.splice(index, 1);
});
}
promise.then(popPromise, popPromise);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ export abstract class CollectorExporterNodeBase<
.then(onSuccess, onError);

this._sendingPromises.push(promise);
promise.finally(() => {
const popPromise = () => {
const index = this._sendingPromises.indexOf(promise);
this._sendingPromises.splice(index, 1);
});
}
promise.then(popPromise, popPromise);
}

onShutdown(): void {}
Expand Down
6 changes: 4 additions & 2 deletions packages/opentelemetry-exporter-zipkin/src/zipkin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,13 @@ export class ZipkinExporter implements SpanExporter {
});
});


this._sendingPromises.push(promise);
promise.finally(() => {
const popPromise = () => {
const index = this._sendingPromises.indexOf(promise);
this._sendingPromises.splice(index, 1);
});
}
promise.then(popPromise, popPromise);
}

/**
Expand Down

0 comments on commit 9ba634e

Please sign in to comment.