Skip to content
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

Strange issue when using alongside with koa #33

Closed
jim-y opened this issue Mar 3, 2016 · 8 comments
Closed

Strange issue when using alongside with koa #33

jim-y opened this issue Mar 3, 2016 · 8 comments

Comments

@jim-y
Copy link

jim-y commented Mar 3, 2016

Hi,

Sorry for linking but I really don't want to copy-paste it here too, so please follow my link to the koa issue I've just created koajs/koa#670 - koa works strange with node-argon2. I don't know why it happens but there is a strange timeout in the hash function if I use argon with koa. Examples in the linked issue. I've set up some easy examples to show the "bug".

Environment

Operating system: Mac OS X Yosemite 10.10.5

Node version: v5.2.0

Argon version: 0.9 (latest)

Cheers

@PlasmaPower
Copy link

I've done some research over at the koa issue (koajs/koa#670) and it appears that argon2 breaks when called from a http server listener. Here's a broken example without koa: https://gist.github.com/PlasmaPower/f3cc2c06875eee760d81

I propose renaming this issue to reflect that it's a problem when used with the http library in general, not just koa.

@ranisalt
Copy link
Owner

ranisalt commented Mar 3, 2016

Please follow #25 which is the same problem. I've been discussing with Nan maintainers too on how to solve this issue, which does not only affects node-argon2 but any package that implements promises on the C++ side.

(Thanks for the report. I myself started this package for use with Koa 😀 )

@PlasmaPower
Copy link

To clarify, this issue is for http servers in general.

@eden
Copy link
Contributor

eden commented Apr 5, 2016

I've run into this issue as well and worked around it by using the synchronous methods instead. Unfortunately, it outputs a warning to the console which pollutes my server logs. Can we get rid of the warning until this is resolved or at least only warn once instead of each time? Happy to submit a pull request if you need...

@ranisalt
Copy link
Owner

ranisalt commented Apr 5, 2016

It's because the synchronous methods will be removed before v1.0. I'm working to fix this promise issue soon.

@ranisalt
Copy link
Owner

ranisalt commented Apr 5, 2016

Marking as duplicate of #25 since they are closely related.

@cjlarose
Copy link

cjlarose commented Apr 7, 2016

One way to fix this issue is to avoid using promises in a C++ module altogether. You can use node-ffi to dynamically load the argon2 library and access it from JavaScript. You can then handle Promises from the JS side and just kind of side-step the problem.

This is the approach I've taken in argon2-ffi. I don't actually handle promises in my library--it's all callback-based. However, for projects seeking to use argon2 in a way that isn't synchronous (blocking), it's a suitable alternative for now.

ranisalt added a commit that referenced this issue Apr 7, 2016
@ranisalt ranisalt closed this as completed Apr 7, 2016
@ranisalt
Copy link
Owner

ranisalt commented Apr 7, 2016

@cjlarose no point in using the same code you already maintain.

I'd also suggest that you maintain promise-based options since that's the direction ES2015 is moving towards and more people are using async/await now 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants