Add extra logging to TaskWithTimeout
This commit is contained in:
parent
19279cfebd
commit
63509b8965
1 changed files with 11 additions and 2 deletions
|
@ -75,6 +75,9 @@ export default function createTaskWithTimeout<T, Args extends Array<unknown>>(
|
||||||
entry.startedAt = Date.now();
|
entry.startedAt = Date.now();
|
||||||
timer = setTimeout(() => {
|
timer = setTimeout(() => {
|
||||||
if (complete) {
|
if (complete) {
|
||||||
|
log.warn(
|
||||||
|
`TaskWithTimeout: ${id} task timed out, but was already complete`
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
complete = true;
|
complete = true;
|
||||||
|
@ -93,8 +96,14 @@ export default function createTaskWithTimeout<T, Args extends Array<unknown>>(
|
||||||
const entry: TaskType = {
|
const entry: TaskType = {
|
||||||
id,
|
id,
|
||||||
startedAt: undefined,
|
startedAt: undefined,
|
||||||
suspend: stopTimer,
|
suspend: () => {
|
||||||
resume: startTimer,
|
log.warn(`TaskWithTimeout: ${id} task suspended`);
|
||||||
|
stopTimer();
|
||||||
|
},
|
||||||
|
resume: () => {
|
||||||
|
log.warn(`TaskWithTimeout: ${id} task resumed`);
|
||||||
|
startTimer();
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
tasks.add(entry);
|
tasks.add(entry);
|
||||||
|
|
Loading…
Reference in a new issue