Tape: Needs to save references to nextTick and friends to avoid side-effects from stubbing

Created on 8 Jun 2016  路  2Comments  路  Source: substack/tape

We got a bug report our way in sinonjs/lolex#66, which basically boils down to that tape ends up using stubbed timing functions and gets stuck. Mocha solves this issue by saving references to all global timing related functions, such as setTimeout, setInterval, nextTick, ..., so that later modifications will not interfere with its internal use of them.

This would be the easiest fix.

Relevant lines that uses nextTick:

bug

Most helpful comment

Absolutely tape should be robust against modification of globals - thanks for the report!

Please file one on through for https://github.com/dominictarr/through/commit/903501acf73d03f584dd572b885c78c1bc9cca8b#diff-168726dbe96b3ce427e7fedce31bb0bcR49 - that's a separate repo.

Your given example though is indeed a cached version of process.nextTick - there's one example of setTimeout in tape code, which I'll fix shortly.

All 2 comments

Yeah, seems like a reasonable way of resolving this - though one might also argue that clocks should never be messed with. But it probably has its uses, so hey

See Also:

Absolutely tape should be robust against modification of globals - thanks for the report!

Please file one on through for https://github.com/dominictarr/through/commit/903501acf73d03f584dd572b885c78c1bc9cca8b#diff-168726dbe96b3ce427e7fedce31bb0bcR49 - that's a separate repo.

Your given example though is indeed a cached version of process.nextTick - there's one example of setTimeout in tape code, which I'll fix shortly.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dcousens picture dcousens  路  8Comments

mkermani144 picture mkermani144  路  6Comments

dcousens picture dcousens  路  3Comments

shaunlebron picture shaunlebron  路  4Comments

jimkang picture jimkang  路  3Comments