Skip to content

remoteStack bug #60

Description

@StarpTech

Question: Why I have two error objects in the remoteStack which point to the same error in the service c ?

I create following scenario:

service-a

const mu = require('mu')({
  dev: process.NODE_ENV !== 'production'
})
const tcp = require('mu-tcp')

// define routing:

mu.inbound({
  role: 'some'
}, tcp.server({
  port: 3000,
  host: '127.0.0.1'
}))

mu.outbound({
  role: 'other'
}, tcp.client({
  port: 3001,
  host: '127.0.0.1'
}))

// define patterns:

mu.define({
  role: 'some',
  cmd: 'sub'
}, function (args, cb) {

  mu.dispatch({
    role: 'other',
    cmd: 'sub',
    a: 1,
    b: 2
  }, function (err, result) {

    if (err) {
      return cb(err);
    }

    cb(null, result);
  })
})

service b

const mu = require('mu')({dev: process.NODE_ENV !== 'production'})
const tcp = require('mu-tcp')

// define routing:

mu.outbound({role: 'some'}, tcp.client({port: 3000, host: '127.0.0.1'}))

// define patterns:

mu.dispatch({ role: 'some', cmd: 'sub', a: 1, b: 2 }, function (err, result) {
  
  console.log(JSON.stringify(err))
})

service c

const mu = require('mu')({
  dev: process.NODE_ENV !== 'production'
})
const tcp = require('mu-tcp')

// define routing:

mu.inbound({
  role: 'other'
}, tcp.server({
  port: 3001,
  host: '127.0.0.1'
}))

// define patterns:

mu.define({
  role: 'other',
  cmd: 'sub'
}, function (args, cb) {
  
  cb(mu.error.wrapRemote(mu.error('invalid'), 1, 500, { msg: 'jesus' }))
  
})

Steps to reproduce

  1. Start service c
  2. Start service a
  3. Start service b

I got following error payload

{
  "data": null,
  "isBoom": true,
  "isServer": true,
  "output": {
    "statusCode": 500,
    "payload": {
      "statusCode": 500,
      "error": "Internal Server Error",
      "message": "An internal server error occurred",
      "mu": {
        "code": 1,
        "error": "service error",
        "message": "invalid"
      }
    },
    "headers": {},
    "mu": {
      "code": 1,
      "error": "service error",
      "message": "invalid"
    }
  },
  "isMu": true,
  "remoteStacks": [{
        "timestamp": 1478711395108,
        "stack": "Error: invalid\n    at makeMuError (E:\\Repositorys\\mu-test\\node_modules\\mu-error\\index.js:56:21)\n    at monoMorphMuError (E:\\Repositorys\\mu-test\\node_modules\\mu-error\\index.js:188:14)\n    at Object.mue [as error] (E:\\Repositorys\\mu-test\\node_modules\\mu-error\\index.js:49:14)\n    at Object.tf (E:\\Repositorys\\mu-test\\service-c.js:22:29)\n    at Object.route (E:\\Repositorys\\mu-test\\node_modules\\mu-router\\index.js:71:14)\n    at Object.dispatch (E:\\Repositorys\\mu-test\\node_modules\\mu\\index.js:87:12)\n    at receive (E:\\Repositorys\\mu-test\\node_modules\\mu-transport\\index.js:56:8)\n    at DestroyableTransform._transform (E:\\Repositorys\\mu-test\\node_modules\\mu-tcp\\driver.js:87:11)\n    at DestroyableTransform.Transform._read (E:\\Repositorys\\mu-test\\node_modules\\readable-stream\\lib\\_stream_transform.js:159:10)\n
        at DestroyableTransform.Transform._write(E: \\Repositorys\\ mu - test\\ node_modules\\ readable - stream\\ lib\\ _stream_transform.js: 147: 83)
        "},{"
        timestamp ":1478711395110,"
        stack ":"
        Error: invalid\ n at Error(native)\ n at Function.wrapRemote(E: \\Repositorys\\ mu - test\\ node_modules\\ mu - error\\ index.js: 132: 19)\ n
        at Object.tf(E: \\Repositorys\\ mu - test\\ service - c.js: 22: 15)\ n at Object.route(E: \\Repositorys\\ mu - test\\ node_modules\\ mu - router\\ index.js: 71: 14)\ n at Object.dispatch(E: \\Repositorys\\ mu - test\\ node_modules\\ mu\\ index.js: 87: 12)\ n at receive(E: \\Repositorys\\ mu - test\\ node_modules\\ mu - transport\\ index.js: 56: 8)\ n at DestroyableTransform._transform(E: \\Repositorys\\ mu - test\\ node_modules\\ mu - tcp\\ driver.js: 87: 11)\ n at DestroyableTransform.Transform._read(E: \\Repositorys\\ mu - test\\ node_modules\\ readable - stream\\ lib\\ _stream_transform.js: 159: 10)\ n at DestroyableTransform.Transform._write(E: \\Repositorys\\ mu - test\\ node_modules\\ readable - stream\\ lib\\ _stream_transform.js: 147: 83)\ n at doWrite(E: \\Repositorys\\ mu - test\\ node_modules\\ readable - stream\\ lib\\ _stream_writable.js: 313: 64)
        "}],"
        message ":"
        invalid ","
        stack ":"
        Error: invalid\ n at Error(native)\ n at Function.wrapRemote(E: \\Repositorys\\ mu - test\\ node_modules\\ mu - error\\ index.js: 132: 19)\ n at Object.route(E: \\Repositorys\\ mu - test\\ node_modules\\ mu - router\\ index.js: 111: 30)\ n at Object.dispatch(E: \\Repositorys\\ mu - test\\ node_modules\\ mu\\ index.js: 87: 12)\ n at receive(E: \\Repositorys\\ mu - test\\ node_modules\\ mu - transport\\ index.js: 56: 8)\ n
        at null. < anonymous > (E: \\Repositorys\\ mu - test\\ node_modules\\ mu - tcp\\ driver.js: 59: 11)\ n at emitOne(events.js: 77: 13)\ n at emit(events.js: 169: 7)\ n
        at readableAddChunk(E: \\Repositorys\\ mu - test\\ node_modules\\ readable - stream\\ lib\\ _stream_readable.js: 198: 18)\ n at Readable.push(E: \\Repositorys\\ mu - test\\ node_modules\\ readable - stream\\ lib\\ _stream_readable.js: 157: 10)
        "}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions