Add extra logging to TaskWithTimeout

This commit is contained in:
Fedor Indutny 2023-01-12 14:00:50 -08:00 committed by GitHub
parent 19279cfebd
commit 63509b8965
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);