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();
timer = setTimeout(() => {
if (complete) {
log.warn(
`TaskWithTimeout: ${id} task timed out, but was already complete`
);
return;
}
complete = true;
@ -93,8 +96,14 @@ export default function createTaskWithTimeout<T, Args extends Array<unknown>>(
const entry: TaskType = {
id,
startedAt: undefined,
suspend: stopTimer,
resume: startTimer,
suspend: () => {
log.warn(`TaskWithTimeout: ${id} task suspended`);
stopTimer();
},
resume: () => {
log.warn(`TaskWithTimeout: ${id} task resumed`);
startTimer();
},
};
tasks.add(entry);