exports = function(arg){
const bcryptjs = require("bcryptjs");
return bcryptjs.hashSync("test", 10);
};
When I run it, I get the error after a certain amount of time. Same response when I use it in a webhook.
Anything I can do?
exports = function(arg){
const bcryptjs = require("bcryptjs");
return bcryptjs.hashSync("test", 10);
};
When I run it, I get the error after a certain amount of time. Same response when I use it in a webhook.
Anything I can do?
Hi @Jo_Rokegem ,
Thank you for contacting MongoDB Community Forums - My name is Josman and I am happy to assist you with this issue.
Currently, there are several constraints for running Realm functions under your Realm Application. Among the other constraints it seems that you are hitting:
Anything I can do?
I reproduced your issue in my Realm App environment and unfortunately, we do not support all npm
libraries. However, let me investigate if there is another library that you can use or if there is a workaround to overcome this situation.
Kind Regards,
Josman
I tried the npm library bcrypt first, but it gave me these errors:
error:
failed to execute source for 'node_modules/bcrypt/bcrypt.js': FunctionError: failed to execute source for 'node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js': FunctionError: failed to execute source for 'node_modules/npmlog/log.js': FunctionError: failed to execute source for 'node_modules/gauge/index.js': FunctionError: failed to execute source for 'node_modules/gauge/has-color.js': TypeError: Cannot access member 'platform' of undefined
at isWin32 (node_modules/gauge/has-color.js:14:10(2))
at node_modules/gauge/has-color.js:11:25(30)
at require (native)
at node_modules/gauge/index.js:17:24(50)
at require (native)
at node_modules/npmlog/log.js:15:21(42)
at require (native)
at node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js:31:19(76)
at require (native)
at node_modules/bcrypt/bcrypt.js:11:26(26)
maybe this helps
Hello @Jo_Rokegem
I tried the npm library bcrypt first, but it gave me these errors:
Yes, I reproduced the same errors as well. Even when trying a different version of the same library. Please, allow me some time to investigate this further and I will reply to you as soon as possible with my findings.
Thank you for your patience on the matter and sorry for the inconvenience this is causing to your application.
Kind Regards,
Josman
Hello @Jo_Rokegem
Have you considered using the crypto
node standard library instead? The crypto.scryptSync
function and other hashing functions in that library will run significantly faster since they are not written in pure JavaScript like bcryptjs. The bcryptjs.hashSync
function ends up being rate limited on our end since it uses pure JavaScript and it’s computationally expensive. I might have found some performance improvements that could be made within our rate limiter, but even when disabling it completely, it takes ~7 seconds to run your bycryptjs function.
At a glance, the “bcrypt” package doesn’t seem to be supported because we currently don’t support process.platform.
Your function using the standard node library, will be as follows:
exports = function(arg){
const crypto = require('crypto');
// Using the factory defaults.
const key1 = crypto.scryptSync('test', 'salt', 10);
console.log(key1.toString('hex')); // '72f47a5f6....b96a9d7'
};
Please let me know if you have any additional questions or concerns regarding the details above.
Kind Regards,
Josman