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

Unhandled rejections are not shown if using newrelic + winston logger #2008

Open
alexey-yarmosh opened this issue Feb 9, 2024 · 4 comments

Comments

@alexey-yarmosh
Copy link

Description

Adding those lines makes app hide unhandled rejections. App just exits nothing related is shown in console:

// index.js

import winston from 'winston';
const logger = winston.createLogger();

throw new Error('this error not shown');

Expected Behavior

...
{"v":0,"level":30,"name":"newrelic","hostname":"MacBook-Pro-Alex.local","pid":54444,"time":"2024-02-09T16:12:19.342Z","msg":"Using New Relic for Node.js. Agent version: 11.10.3; Node version: v20.11.0."}
{"v":0,"level":40,"name":"newrelic","hostname":"MacBook-Pro-Alex.local","pid":54444,"time":"2024-02-09T16:12:19.342Z","msg":"New Relic for Node.js in worker_threads is not officially supported. Not starting! To bypass this, set `config.worker_threads.enabled` to true in configuration."}
file:///Users/baderfall/Documents/web/testing/nr-winston-demo/index.js:5
throw new Error('this error not shown');
      ^

Error: this error not shown
    at file:///Users/baderfall/Documents/web/testing/nr-winston-demo/index.js:5:7
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async loadESM (node:internal/process/esm_loader:28:7)
    at async handleMainPromise (node:internal/modules/run_main:113:12)

Node.js v20.11.0

Troubleshooting or NR Diag results

Steps to Reproduce

https://github.com/alexey-yarmosh/nr-winston-demo

Your Environment

Node version: v20.11.0
Operating System and version: MacOS 14.3

Additional context

@workato-integration
Copy link

@newrelic-node-agent-team newrelic-node-agent-team added this to Triage Needed: Unprioritized Features in Node.js Engineering Board Feb 9, 2024
@bizob2828
Copy link
Member

bizob2828 commented Feb 9, 2024

@alexey-yarmosh sorry the troubles. I was able to trace it down. Our instrumentation sets handleExceptions to true which means these get forwarded to new relic logs feature.

screenshot 2024-02-09 at 12 00 08 PM

This is behaving as designed. Are you asking to actually see these and not have winston log and forward these to New Relic logs?

@bizob2828 bizob2828 removed the bug label Feb 9, 2024
@alexey-yarmosh
Copy link
Author

Indeed error is shown in New Relic logs. But all other logs are shown both there and in stdout. So to me, expected behaviour would be to see unhandled exception in stdout as well.

@bizob2828
Copy link
Member

Yea let me dig. I'm not sure we can have both meaning it'll enqueue uncaught exceptions to New Relic logs and see it in stdout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Node.js Engineering Board
  
Triage Needed: Unprioritized Features
Development

No branches or pull requests

2 participants