Skip to content

Commit

Permalink
fix(@opentelemetry/exporter-collector): remove fulfilled promises cor…
Browse files Browse the repository at this point in the history
…rectly
  • Loading branch information
aabmass committed Dec 22, 2020
1 parent a2304c9 commit b983dcf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Expand Up @@ -68,19 +68,14 @@ export abstract class CollectorExporterBrowserBase<
const serviceRequest = this.convert(items);
const body = JSON.stringify(serviceRequest);

const promise = new Promise(resolve => {
const promise = new Promise<void>(resolve => {
const _onSuccess = (): void => {
onSuccess();
_onFinish();
resolve();
};
const _onError = (error: collectorTypes.CollectorExporterError): void => {
onError(error);
_onFinish();
};
const _onFinish = () => {
resolve();
const index = this._sendingPromises.indexOf(promise);
this._sendingPromises.splice(index, 1);
};

if (this._useXHR) {
Expand All @@ -97,5 +92,10 @@ export abstract class CollectorExporterBrowserBase<
}
});
this._sendingPromises.push(promise);
const _onFinish = () => {
const index = this._sendingPromises.indexOf(promise);
this._sendingPromises.splice(index, 1);
};
promise.then(_onFinish);
}
}
Expand Up @@ -40,7 +40,7 @@ export abstract class CollectorExporterNodeBase<
httpAgentOptions: http.AgentOptions | https.AgentOptions = {};
constructor(config: CollectorExporterNodeConfigBase = {}) {
super(config);
if ((config as any).metadata) {
if ('metadata' in config) {
this.logger.warn('Metadata cannot be set when using http');
}
this.headers =
Expand Down

0 comments on commit b983dcf

Please sign in to comment.