-
-
Notifications
You must be signed in to change notification settings - Fork 589
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
zwave-js override global Promise rejection mechanism which cause side-effects #4272
Comments
After investigating a bit more, it seems this Sentry lib is setting up a global unhandledRejection handler: |
Sentry is our error reporting, which needs to be able to catch unhandled rejections, otherwise that would defeat its purpose. I haven't figured out if (and how) its possible to limit Sentry to errors originating from zwave-js. If necessary, I could add an env variable to disable initializing Sentry - how does that sound? |
Maybe disabling the unhandled rejection integration and instead using the |
Both solutions look great. Maybe disabling entirely Sentry with an env variable is the easiest way to remove all possible side-effects (because I'm not sure this is the only one?), but the 2nd option works too! |
Scratch that - doesn't work at all. I'm just going to make Sentry opt-in. |
This will be fixed in the v9 release |
Thank you so much for having a look into it 🙏 |
@AlCalzone Just read your comment in the PR :
The Sentry listener has an impact on any version of Node (even Node 16), because the app can register a On embedded home automation software (alarm system), a hard crash (without the time to save data/make sure everything is fine) is really not wanted ! |
You've got a point there. I'll change the sentry listener to behave like Node.js on "warn" level. |
According to my tests, https://docs.sentry.io/platforms/node/configuration/integrations/default-integrations/#onunhandledrejection with the mode |
Is your problem within Home Assistant (Core or Z-Wave JS Integration)?
NO, my problem is NOT within Home Assistant or the ZWave JS integration
Is your problem within ZWaveJS2MQTT?
NO, my problem is NOT within ZWaveJS2MQTT
Checklist
I have checked the troubleshooting section and my problem is not described there.
I have read the changelog and my problem was not mentioned there.
Describe the bug
Hi,
I'm the core maintainer of the open-source project Gladys Assistant, and we are trying to migrate to this library for our Z-Wave integration.
First, congrats on the work on this great lib 🙂
What causes the bug?
It seems that this library loads a third-party NPM module, @sentry/utils, a library that is not intended for production use and that override some Promise rejection behavior in the global scope.
It causes
unHandledPromiseRejection
to be handled differently as soon as we require thezwave-js
module, and cause side-effects with other librairies.Steps to reproduce the behavior
I managed to write a very simple script to reproduce the issue:
If you execute this script with the require commented, you'll get this result (in Node 14):
As soon as I uncomment the require, I get this result:
As you can see, the zwave-js library mutate a global object and cause errors to be thrown differently.
Which branches or versions?
version:
node-zwave-js
branch: 8.11.6The text was updated successfully, but these errors were encountered: