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

NodeJS - silence exit when enabled is false and captureUncaught is true #1099

Open
francois06 opened this issue Mar 24, 2023 · 0 comments
Open
Labels

Comments

@francois06
Copy link

francois06 commented Mar 24, 2023

First of all, thank you for this amazing library!

I have found an issue with Node.JS when an error occurs in development mode & when rollbar is not enabled.

Use case :

server.js

const app = require('./app');
app.start(config.server.port);

app.js

//...
throw new Error('lorem');
// ...

server.js require app.js and then I run

node server.js

Error: lorem (with trace) 👍
==> ok

Now I add rollbar with enabled: false
server.js

const rollbar = new Rollbar({
	accessToken: 'xxx',
	captureUncaught: true,
	captureUnhandledRejections: true,
	enabled: false,
});
const app = require('./app');
app.start(config.server.port);

node server.js

no error, no trace, silent exit 👎

Other tests :

if enabled is true with verbose: true
=> Error is shown with trace

if enabled is true with verbose: false
=> silent exit no trace

if enabled is false with verbose: true
==> Wrong error is shown :

Error: Rollbar is not enabled
at Notifier.log
at Rollbar._log

IMHO problems come from this test, rollbar should re-throw error when it s not enabled.
Or maybe when enabled is false captureUncaught should be automatically false

if enabled is false with captureUncaught: false
==> ok

My current trick to make this work :

captureUncaught: (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'staging'),
enabled: (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'staging'),

I hope my explanations are clear.

Environment:

tested on Node.js 16.x && 18.x
rollbar 2.26.1 (NPM module)

@francois06 francois06 changed the title NodeJS - silence exit with enabled false and captureUncaught true NodeJS - silence exit when enabled is false and captureUncaught is true Mar 24, 2023
@mudetroit mudetroit added the node label Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants