Node: http server response cannot be used in promises

Created on 11 Mar 2016  路  7Comments  路  Source: nodejs/node

https://gist.github.com/anonymous/1b48c89fb63d7cc02021
http://i.imgur.com/r6DYhH2.png

i have the code i pasted above when that user.login function runs server does nothing but waiting and when connection got timeout or terminated by user script logs the results to console i cant end the response those previous res.fails work fine just this part makes issue and unless req is terminated it does not even step inside the then block

the demo
test

promises

All 7 comments

This doesn't seem like a node issue to me.

One thing that sticks out in the code you've provided is that you're not handling the case when data.status != "sucess". Also, might the issue be that data.status === 'success'?

@mscdex controls does not matter because program is not stepping inside the block and actually i dont even need to worry about success because its just because of habit i have a status there in case of failure my login function changes the promise status into rejected which means the catch block will handle that just the iissue the login function never returns something while request is on the process and when it timesout programs returning the expected value and loging to the console

test

heres the demo showig the issue its nothing about wrong controls etc

so i guess this is a real bug in nodejs or particularly promises i had a similar issue with events before the promise worked only once and when the eventHandler triggered again it aint do anything i solved that by using callback approach but in this case it means me changing entire class is there a common problem with promise implementation in nodejs ?

https://github.com/ranisalt/node-argon2/issues/37#issuecomment-195683009

it turns out that the bug is about argon2 nodejs package so nothing to do with nodejs

I'll reopen it for now, it might be related with the way we handle microtask queue: https://github.com/ranisalt/node-argon2/issues/25

Was this page helpful?
0 / 5 - 0 ratings