Skip to content

Commit 14db72f

Browse files
authored
fix: handle missing stack when throwing recursion errors (#401)
* fix: handle missing stack when throwing recursion errors * lint
1 parent f434b69 commit 14db72f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/fake-timers-src.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ const globalObject = require("@sinonjs/commons").global;
109109
* @property {number} createdAt
110110
* @property {boolean} immediate
111111
* @property {number} id
112+
* @property {Error} [error]
112113
*/
113114

114115
/**
@@ -208,8 +209,8 @@ function withGlobal(_global) {
208209
let isNearInfiniteLimit = false;
209210

210211
/**
211-
* @param clock
212-
* @param i
212+
* @param {Clock} clock
213+
* @param {number} i
213214
*/
214215
function checkIsNearInfiniteLimit(clock, i) {
215216
if (clock.loopLimit && i === clock.loopLimit - 1) {
@@ -309,14 +310,18 @@ function withGlobal(_global) {
309310
}
310311

311312
/**
312-
* @param clock
313-
* @param job
313+
* @param {Clock} clock
314+
* @param {Timer} job
314315
*/
315316
function getInfiniteLoopError(clock, job) {
316317
const infiniteLoopError = new Error(
317318
`Aborting after running ${clock.loopLimit} timers, assuming an infinite loop!`
318319
);
319320

321+
if (!job.error) {
322+
return infiniteLoopError;
323+
}
324+
320325
// pattern never matched in Node
321326
const computedTargetPattern = /target\.*[<|(|[].*?[>|\]|)]\s*/;
322327
let clockMethodPattern = new RegExp(

0 commit comments

Comments
 (0)