Skip to content

Commit

Permalink
fix: ensure onError is only called once
Browse files Browse the repository at this point in the history
  • Loading branch information
pichlermarc committed Aug 5, 2024
1 parent ec37153 commit c365399
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,13 @@ export abstract class OTLPExporterBrowserBase<
.then(response => {
if (response.status === 'success') {
onSuccess();
return;
}
if (response.status === 'failure' && response.error) {
} else if (response.status === 'failure' && response.error) {
onError(response.error);
}
if (response.status === 'retryable') {
} else if (response.status === 'retryable') {
onError(new OTLPExporterError('Export failed with retryable status'));
} else {
onError(new OTLPExporterError('Export failed with unknown error'));
}
onError(new OTLPExporterError('Export failed with unknown error'));
}, onError);

this._sendingPromises.push(promise);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,13 @@ export abstract class OTLPExporterNodeBase<
.then(response => {
if (response.status === 'success') {
onSuccess();
return;
}
if (response.status === 'failure' && response.error) {
} else if (response.status === 'failure' && response.error) {
onError(response.error);
}
if (response.status === 'retryable') {
} else if (response.status === 'retryable') {
onError(new OTLPExporterError('Export failed with retryable status'));
} else {
onError(new OTLPExporterError('Export failed with unknown error'));
}
onError(new OTLPExporterError('Export failed with unknown error'));
}, onError);

this._sendingPromises.push(promise);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,13 @@ export abstract class OTLPGRPCExporterNodeBase<
.then(response => {
if (response.status === 'success') {
onSuccess();
return;
}
if (response.status === 'failure' && response.error) {
} else if (response.status === 'failure' && response.error) {
onError(response.error);
}
if (response.status === 'retryable') {
} else if (response.status === 'retryable') {
onError(new OTLPExporterError('Export failed with retryable status'));
} else {
onError(new OTLPExporterError('Export failed with unknown error'));
}
onError(new OTLPExporterError('Export failed with unknown error'));
}, onError);

this._sendingPromises.push(promise);
Expand Down

0 comments on commit c365399

Please sign in to comment.