Skip to content

Commit

Permalink
chore: replace Promise.finally with .catch and .then
Browse files Browse the repository at this point in the history
  • Loading branch information
aabmass committed Aug 9, 2021
1 parent 3945af0 commit d6eb88c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
Expand Up @@ -64,10 +64,11 @@ export abstract class CollectorExporterNodeBase<
const promise = new Promise<void>((resolve, reject) => {
this._send(this, objects, resolve, reject);
})
.then(onSuccess, onError);
.then(onSuccess, onError)
.catch(diag.debug);

this._sendingPromises.push(promise);
promise.finally(() => {
promise.then(() => {
const index = this._sendingPromises.indexOf(promise);
this._sendingPromises.splice(index, 1);
});
Expand Down
Expand Up @@ -50,10 +50,11 @@ export abstract class CollectorExporterNodeBase<
const promise = new Promise<void>((resolve, reject) => {
this._send(this, objects, this.compression, resolve, reject);
})
.then(onSuccess, onError);
.then(onSuccess, onError)
.catch(diag.debug);

this._sendingPromises.push(promise);
promise.finally(() => {
promise.then(() => {
const index = this._sendingPromises.indexOf(promise);
this._sendingPromises.splice(index, 1);
});
Expand Down
Expand Up @@ -83,10 +83,11 @@ export abstract class CollectorExporterBrowserBase<
sendWithBeacon(body, this.url, resolve, reject);
}
})
.then(onSuccess, onError);
.then(onSuccess, onError)
.catch(diag.debug);

this._sendingPromises.push(promise);
promise.finally(() => {
promise.then(() => {
const index = this._sendingPromises.indexOf(promise);
this._sendingPromises.splice(index, 1);
});
Expand Down
Expand Up @@ -79,10 +79,11 @@ export abstract class CollectorExporterNodeBase<
reject
);
})
.then(onSuccess, onError);
.then(onSuccess, onError)
.catch(diag.debug);

this._sendingPromises.push(promise);
promise.finally(() => {
promise.then(() => {
const index = this._sendingPromises.indexOf(promise);
this._sendingPromises.splice(index, 1);
});
Expand Down
6 changes: 4 additions & 2 deletions packages/opentelemetry-exporter-zipkin/src/zipkin.ts
Expand Up @@ -85,10 +85,12 @@ export class ZipkinExporter implements SpanExporter {
resolve();
resultCallback(result);
});
});
})
.catch(diag.debug);


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

0 comments on commit d6eb88c

Please sign in to comment.