Skip to content

Commit 87159f0

Browse files
committed
Improve error stack traces for async errors
1 parent 9007a67 commit 87159f0

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/wait-for.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,16 @@ function waitFor(
6363
}
6464

6565
function onTimeout() {
66-
onDone(lastError || timedOutError, null)
66+
let error = timedOutError
67+
if (lastError) {
68+
error = lastError
69+
const userStackTrace = timedOutError.stack
70+
.split('\n')
71+
.slice(1)
72+
.join('\n')
73+
error.stack = `${error.stack.split('\n')[0]}\n${userStackTrace}`
74+
}
75+
onDone(error, null)
6776
}
6877
})
6978
}

0 commit comments

Comments
 (0)