senecajs / seneca

A microservices toolkit for Node.js.
http://senecajs.org
MIT License
3.95k stars 314 forks source link

Decoration is bound to the wrong this-ref in v3.30.0 #920

Open lilsweetcaligula opened 1 year ago

lilsweetcaligula commented 1 year ago
const Seneca = require('..')

const si = Seneca()

si.decorate('lorem', function (self) {
  console.log(this === self)
})

si.add('hello:world', function (args, reply) {
  const delegate = this.delegate()

  // logs true (as expected) in master (p4.0.0-t.1.p.1)
  // logs false (incorrect) in v3.30.0
  delegate.lorem(delegate)

  reply()
})

si.ready(() => {
  si.act('hello:world', () => {})
})