Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swallowing Error instance included in context and replacing by {}. #270

Open
BartoszRak opened this issue Feb 12, 2020 · 0 comments
Open

Comments

@BartoszRak
Copy link

Your package uses https://www.npmjs.com/package/@pm2/agent-node this one, so if we notifyError() that finally use WS agent to send our data out then WS agent make

  send (channel: string, payload: Object) {
    return this.agent.send(channel, this.getFormattedPayload(channel, payload)) ? 0 : -1
  }

where agent is:

const AgentNode = require('@pm2/agent-node')
...
...
...
this.agent = new AgentNode(this.config, this.process)

And if we dig into https://github.com/keymetrics/pm2-io-agent-node/blob/master/src/transport.js we find out that sending is handled by:

this.ws.send(JSON.stringify(packet))

Problem is that JSON.stringify() is not able to stringify Error instance, so If we put Error instance into our context we are going to see just {} which is annoying.

So I propose to maybe handle remapping part of context if its Error instance or something like that? But not sure it should be package or developer responsibility yet 🙆‍♂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant