Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorhdzg committed Dec 14, 2023
1 parent 6bbbb1e commit 0d1a1d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,7 @@ export abstract class BatchLogRecordProcessorBase<T extends BufferConfig>
);
}
})
.catch(error => {
globalErrorHandler(error);
});
.catch(globalErrorHandler);

const pendingResources = logRecords
.map(logRecord => logRecord.resource)
Expand All @@ -192,9 +190,7 @@ export abstract class BatchLogRecordProcessorBase<T extends BufferConfig>
} else {
return Promise.all(
pendingResources.map(resource => resource.waitForAsyncAttributes?.())
).then(doExport, err => {
globalErrorHandler(err);
});
).then(doExport, globalErrorHandler);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,19 @@ export class SimpleLogRecordProcessor implements LogRecordProcessor {
);
}
})
.catch(error => {
globalErrorHandler(error);
});
.catch(globalErrorHandler);

// Avoid scheduling a promise to make the behavior more predictable and easier to test
if (logRecord.resource.asyncAttributesPending) {
const exportPromise = logRecord.resource.waitForAsyncAttributes?.().then(
() => {
const exportPromise = logRecord.resource
.waitForAsyncAttributes?.()
.then(() => {
// Using TS Non-null assertion operator because exportPromise could not be null in here
// if waitForAsyncAttributes is not present this code will never be reached
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this._unresolvedExports.delete(exportPromise!);
return doExport();
},
err => globalErrorHandler(err)
);
}, globalErrorHandler);

// store the unresolved exports
if (exportPromise != null) {
Expand Down

0 comments on commit 0d1a1d3

Please sign in to comment.