senecajs / seneca-transport

Seneca micro-services message transport over TCP and HTTP.
MIT License
63 stars 45 forks source link

Issue with seneca-id header #159

Open bernitorres opened 6 years ago

bernitorres commented 6 years ago

I added a new relic plugin to my seneca microservice, so requests can be logged with a name that makes sense instead of being grouped under /*. After adding this plugin, requests started to fail with the following error:

"notice":"seneca: Action role:movements failed: \"value\" required in setHeader(\"seneca-id\", value).","code":"act_execute","err":

This is the wrapper:

const newrelic = require('newrelic');
const _ = require('lodash');

module.exports = function logger() {
  const seneca = this;
  seneca.wrap('role:*', function wrapper(msg, respond) {
    newrelic.setTransactionName(`role:${msg.role}, cmd:${msg.cmd}`);
    this.prior(msg, respond);
  });
};

Usage of the plugin: this.seneca.use(newRelicPlugin);

What could be causing the seneca-id header to disappear? Is it because of the wrap function? Is there a better way to do this?