double callback! warning
See original GitHub issueI noticed I was getting a double callback warning in quite a few of my tests using supertest.
I found the issue was with how I was using expect and end as follows
request(app)
.get('/something')
.expect(200, function (res) {
// some logic
return false
})
.end(done);
Changing that to the following resolved the issue for me
request(app)
.get('/something')
.expect(function (res) {
// some logic
return false;
})
.expect(200, done);
To see the double callback warning, see this example
Note that this is using express 4.4.1 and supertest 0.13.0
Issue Analytics
- State:
- Created 9 years ago
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Issue #141 · ladjs/supertest - double callback! warning - GitHub
I noticed I was getting a double callback warning in quite a few of my tests using supertest. I found the issue was...
Read more >node.js - Chai http - double callback issue - Stack Overflow
catch() are getting called, resulting in the done callback being called twice. Here's a solution using .then/.catch , combined with Mocha's ...
Read more >Debugging double-callback bugs in node.js
Our callback gets called twice – which isn't so bad with things that don't care like console. log and console. warn , but...
Read more >Callbacks in App Designer - MATLAB & Simulink - MathWorks
Write callbacks to control the behavior of apps you create in App Designer. ... For example, sliders have two callback properties: ValueChangedFcn and ......
Read more >How to prevent disasters caused by the callback getting called ...
I guess you could set a flag when you send the callback function, clear it the first callback, and then ignore the callback...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just need to remove the
.end()
call from the request and handle the returnedPromise
.This should be documented, really confusing with
co-supertest
. https://github.com/avbel/co-supertest/issues/9I think I get an error connected with this question. Here is my test:
but if I change it with:
Now everything works. Even if I set a wrong code like 400 I get an exception that I got 200 instead of 400. Is this connected with this issue?