mocha: Uncaught TypeError: Cannot read property 'currentRetry' of undefined
Tested on Mocha 2.5.3.
When uncaught error is thrown during “before” phase additional “Uncaught TypeError: Cannot read property ‘currentRetry’ of undefined” error is thrown from mocha.
Simple test case:
'use strict';
describe('test', function () {
before(function () {
require('http').createServer().listen(1);
});
it('something', function () {
});
});
output:
test
1) "before all" hook
2) Uncaught error outside test suite
0 passing (27ms)
2 failing
1) test "before all" hook:
Uncaught Error: listen EACCES 0.0.0.0:1
at Object.exports._errnoException (util.js:953:11)
at exports._exceptionWithHostPort (util.js:976:20)
at Server._listen2 (net.js:1240:19)
at listen (net.js:1289:10)
at Server.listen (net.js:1385:5)
at Context.<anonymous> (test/test.js:5:40)
2) test Uncaught error outside test suite:
Uncaught TypeError: Cannot read property 'currentRetry' of undefined
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 19 (11 by maintainers)
Commits related to this issue
- fix: fix uncaught TypeError if error occurs on next tick, closes #2315 — committed to 1999/mocha by deleted user 8 years ago
- fix: fix uncaught TypeError if error occurs on next tick, closes #2315 — committed to 1999/mocha by deleted user 8 years ago
- attempt windows-friendly reproducible case for #2315 — committed to mochajs/mocha by boneskull 8 years ago
- attempt windows-friendly reproducible case for #2315 — committed to mochajs/mocha by boneskull 8 years ago
- Merge remote-tracking branch 'upstream/master' into fix/required-test-files-cache * upstream/master: attempt windows-friendly reproducible case for #2315 fix: fix uncaught TypeError if error occu... — committed to 1999/mocha by deleted user 8 years ago
- fix: fix uncaught TypeError if error occurs on next tick, closes #2315 (#2439) — committed to TwineHealth/mocha by 1999 8 years ago
- attempt windows-friendly reproducible case for #2315 — committed to TwineHealth/mocha by boneskull 8 years ago
@ljharb @1999 A PR was sent (#2439) that needs some review.
Hey guys! 🙂
Just a quick thought: If this is in the context of async setup code, shouldn’t we then use the
done
callback to tell Mocha about that? 🤔I mean something like this:
In this case it the failure message seems to be more clear:
Which makes me think that this may be categorized as a slight misuse instead of a bug. What do you guys think? 🤓
@boneskull @ksuszka @1999
I’m still running into this issue although it has said to be fixed. I’m running mocha 6.2.2 though. Any help?
Error
Function being called in before:
Assume user exists as I can console log it and the test is running and using it.
Any ideas?
@ljharb If I had to guess, somewhere between 0 and 7 days from now.