-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Egoing has reported an issue that he could not see the result of the following code:
var 입력한비밀번호 = '1111';
var 소금의크기 = 32;
var 암호화반복횟수 = 10000;
var 암호의길이 = 32;
var crypto = require('crypto');
crypto.randomBytes(소금의크기, function(오류, 소금){
crypto.pbkdf2(입력한비밀번호, 소금, 암호화반복횟수, 암호의길이, 'sha512', function(오류, 생성된암호){
console.log(생성된암호.toString('hex'));
});
});This is due to the current nodejs kernel just goes through the synchronous part until it sends the execution result and callbacks generated by the user code are executed later.
We need a "blocking" mechanism until all user callbacks finish as well as temporarily removing existing sorna-side callbacks from the event loop.
As the result, I have found a small hacky open source project that uses C++ addon to access uv_run() function, and patched it to implement a blocking call until all callbacks finish:
abbr/deasync#53
Then, I have added unref() / ref() support to zeromq.node project:
JustinTulloss/zeromq.node#503
Now we can implement a proper blocking call for nodejs4 kernel.