-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Agent executes "end()" callback before setting cookies #314
Comments
can you provide a runnable example where it fails? |
just put this file in a test/node folder. Or how want me to do it? |
would be really great if it was something I could just copy paste and run with node :) nvm ill fix it my self |
…lback. test included
Ping. Just spent a hour trying to figure out why this wasn't working just to find this issue. |
Hmm... I have not really messed with the agent additions much. Maybe @hunterloftis would have a thought or two before I dig in. |
Oh what a crappy bug, lost a lot of time on this one. While I don't have a patch for it, here's a way to work around it: agent
.post('/queue/4/status')
.expect(200, status)
.end(function (err) {
process.nextTick(function () {
cb(err);
});
}); Running the callback in the next tick ensures that the next request will only happen once the cookies are set. |
I made a pull request #354 with a possible solution. But it fails travis build on node version 0.8 which appears to be a general issue right now I noticeв that all latest builds crash on it. |
…lback. the solution is rearranging event listeners of the Request making sure that first listener is the one that sets cookies. test included
any updates on this? |
seems no. I think my fix is ok: |
it still doesn't work for me. |
Oh nevermind, its in node 0.8 |
@madhums okok, forget 0.8 |
Hit by this bug. |
+1 |
…lback. the solution is rearranging event listeners of the Request making sure that first listener is the one that sets cookies. test included removed 0.8 node.js from travis config
+1 I've lost days to this. |
Has this been merged in and released? |
I don't think it has. I will take a look this week. |
+1 |
Just lost like 4 hours on this. +1 on merging and release soon. |
The PR needs to be reworked. I think we need a cleaner way to do it than the way the PR is doing it. |
👍 to this. |
How it's possible that such an import bug is not yet fixed. Why this testing library is needed if it can't handle cookies at all. Struggled with it for enough time. Now thinking about replacing controller testing with something else. Perhaps e2e testing instead. |
Fixed by 04a04e2 |
when using agent to keep persistent cookies it executes end callback before agent saves cookies and the next request might not have these cookies set.
here is an example of test that fails when it should not.
https://gist.github.com/vsuhanov/8599800
possible solution:
The text was updated successfully, but these errors were encountered: