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
Restart of JS-Adapter when error in Promise function #1022
Comments
Is the instance really restarted? Please post more log |
Here the output of the main log (sorry for the crazy icons):
|
I checked it and yes it seems that since node.js 16 "Unhandled rejections" like in your case can be grabbed with a listener (and we do this), but the node process will exit in any case once this happens :-( |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days. Please check if the issue is still relevant in the most current version of the adapter and tell us. Also check that all relevant details, logs and reproduction steps are included and update them if needed. Thank you for your contributions. |
nodejs: v18.18.2 io-package.json: Testscript:
Log:
|
@ticaki Yes, because it is also an unhandled exception. throw new Error('test'); |
Test and report requested by Apollon77. :) to test this: ioBroker/ioBroker.js-controller#844 (comment) |
Looks like the "new" ioBroker/ioBroker.js-controller#2123
Mhhh - if specified, the adapter won't start in compact mode anymore? Are there any statistics, how many users are running their system in compact mode and have the JavaScript adapter installed @Apollon77 ? |
Start not anymore? this was never reported and yes there should be a log when using compact but there should be no error or such. |
If compact is allowed, "common.nodeProcessParams" is not activated, regardless of whether it is used.
|
Of course - but the warning will be raised when So compact mode support must be disabled completely: ioBroker.javascript/io-package.json Line 142 in 939b0b0
Otherwise the warning will be raised on every start. Even if the instance is not running in compact mode. That will lead to many issues (because it should be reported to the developers). |
I would more fevor then a js-controller issue to only log this message if compact is szpported and also active foir this instance ... to then log on start :-) In fact till now - to be honest additionally - this setting do not seem to have a noticeable solving effect for issues with uhancled rejections :-) |
When there is an error in a function in a promise (see code below) then the adapter cannot identify where the error comes from and restarts the adapter. I hope that I have created a reasonable example code, because I have changed my implementation meanwhile to node-fetch and fixed all potential errors. It at least did what I described when I tried it here.
function callFunction(testVar) { console.log(testMeVar); } var request = require('then-request'); request('GET', 'http://example.com').done(function (res) { callFunction('test'); })
Expected behavior
The code should raise an error, but the instance should not be restarted.
Screenshots & Logfiles
20:53:18.081 | error | javascript.0 (527) script.js.Test.TestScript: ReferenceError: testMeVar is not defined
20:53:18.081 | error | javascript.0 (527) at callFunction (script.js.Test.TestScript:2:17)
20:53:18.082 | error | javascript.0 (527) at script.js.Test.TestScript:6:5
20:53:18.205 | error | host.iobroker Caught by controller[0]: at callFunction (script.js.Test.TestScript:364:17)
20:53:18.205 | error | host.iobroker Caught by controller[0]: at script.js.Test.TestScript:368:5
Versions:
The text was updated successfully, but these errors were encountered: