seneca
seneca copied to clipboard
Using a plugin with a Seneca instance passed as an option, crashes the stack
Ave! I believe I have discovered a bug. When I create a plugin, use it and pass another Seneca instance as an option to the plugin, the code mysteriously crashes the stack:
const Seneca = require('seneca')
function my_plugin(options) {
}
const lambda = Seneca()
const tau = Seneca()
tau.use(my_plugin, { seneca: lambda })
// ERROR: Maximum call stack size exceeded
My Seneca version is at 3.23.3
and it's the only dependency I have in my package.json
file.
A quick workaround would be to pass a function wrapping the Seneca instance, instead of passing the Seneca instance directly:
const Seneca = require('seneca')
function my_plugin(options) {
}
const lambda = Seneca()
const tau = Seneca()
tau.use(my_plugin, { seneca: () => lambda })
// OK
I was able to track down the offending line: https://github.com/senecajs/seneca/blob/master/lib/plugin.ts#L554