node.bcrypt.js: Domains can't catch errors inside bcrypt callbacks
note from maintainers
Domains are deprecated
I’ve noticed that errors inside bcrypt callbacks can’t be caught by domains.
Minimal test case:
var bcrypt = require('bcrypt')
, domain = require('domain')
, d = domain.create()
d.on('error', function (e) {
console.log('error caught: ' + e)
})
d.run(function () {
bcrypt.genSalt(10, function() {
throw new Error('this one fails')
});
})
I expect to see ‘error caught: this one fails’. It doesn’t appear.
However, if you run the domain again, now both errors are caught:
var bcrypt = require('bcrypt')
, domain = require('domain')
, d = domain.create()
d.on('error', function (e) {
console.log('error caught: ' + e)
})
d.run(function () {
bcrypt.genSalt(10, function() {
throw new Error('this one fails')
});
})
d.run(function () {
throw new Error('this one works')
})
Now both errors are caught by the domain.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 18 (1 by maintainers)
As another somewhat scarier datapoint, in the Node 0.10.45 REPL, the following commands crash the shell: