Ensure that waitForAll functions catch and log thrown errors
This commit is contained in:
parent
45fcf827dd
commit
9e54f55c22
6 changed files with 36 additions and 5 deletions
|
@ -5,6 +5,7 @@ import PQueue from 'p-queue';
|
|||
|
||||
import { sleep } from './sleep';
|
||||
import * as log from '../logging/log';
|
||||
import * as Errors from '../types/errors';
|
||||
import { clearTimeoutIfNecessary } from './clearTimeoutIfNecessary';
|
||||
|
||||
declare global {
|
||||
|
@ -20,7 +21,15 @@ declare global {
|
|||
window.batchers = [];
|
||||
|
||||
window.waitForAllBatchers = async () => {
|
||||
await Promise.all(window.batchers.map(item => item.flushAndWait()));
|
||||
log.info('batcher#waitForAllBatchers');
|
||||
try {
|
||||
await Promise.all(window.batchers.map(item => item.flushAndWait()));
|
||||
} catch (error) {
|
||||
log.error(
|
||||
'waitForAllBatchers: error flushing all',
|
||||
Errors.toLogFormat(error)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export type BatcherOptionsType<ItemType> = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue