Skip to content

Asynchronous interface #16

Closed
Closed
@6uliver

Description

@6uliver

First of all, your package is great, thank you!

My issue is a question/suggestion: The official Node.JS documentation says that the crypto.randomBytes method can block the execution:

The crypto.randomBytes() method will not complete until there is sufficient entropy available. This should normally never take longer than a few milliseconds. The only time when generating the random bytes may conceivably block for a longer period of time is right after boot, when the whole system is still low on entropy.

You can find a question whether should we use sync or async:
nodejs/help#457

I don't have any performance issue yet, but I would like to use this package in production. In my use case I expect to have a lot of call to this function so it would be better if it did not block the execution. I know that a few milliseconds as the documentation says is not a lot for a single call but in a server environment a lot of few milliseconds call can block other tasks.

I suggest that we should have an interface (eg. cryptoRandomStringAsync) which does similar things but returns a Promise. What do you think?

If you like the idea but don't have time for this I can implement it and send a PR.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions