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 exception - supposedly due to lagging operations in OnReady() #178

Closed
git-kick opened this issue Aug 21, 2023 · 3 comments
Closed
Assignees
Labels
bug Something isn't working maintenance e.g. requested by ioBroker Checker or Dependabot
Milestone

Comments

@git-kick
Copy link
Owner

git-kick commented Aug 21, 2023

Describe the bug
This was initially reported by Sentry and then falsely addressed to ioBroker.js-controller

To Reproduce
Steps to reproduce the behavior:

  1. Start adapter
  2. Stop adapter instantly - while is is still initializing (in fact, it is unlikely to hit the "right" point in time here)
  3. See error on Sentry

Expected behavior
All adapter operations should be safely terminated before adapter shuts down.

Screenshots & Logfiles
See ioBroker.js-controller

Versions:

  • E3/DC S10
  • Adapter version: v1.2.2
  • JS-Controller version: v4.0.24
  • Node version: v18.17.0
  • Operating system: Ubuntu 22.04 LTS
@git-kick git-kick self-assigned this Aug 21, 2023
@git-kick git-kick added bug Something isn't working maintenance e.g. requested by ioBroker Checker or Dependabot labels Aug 21, 2023
@git-kick git-kick added this to the V1.2.4 milestone Aug 21, 2023
@git-kick
Copy link
Owner Author

git-kick commented Aug 21, 2023

There are two action points:

  1. Avoid calling setState() anynchronously (see mcm1957's post) - use await setState()
    1a. in onReady() - done
    1b. in other occurences all over main.js - no change: await is only allowed at top level or in async functions
  2. Clarify meaning of setObjectNotExists() vs setObjectNotExistsAsync() and use it consitently
    2a. in onReady() - done: initialization in onReady should use await setObjectNotExistsAsync(); see adapterdev
    2b. in other occurences all over main.js - no change: in storeValue(), use synchronous setObjectNotExists() with callback

@git-kick
Copy link
Owner Author

git-kick commented Aug 21, 2023

how-to-async.md by AlCalzone is a good (German) intro to (a)synchronicity in js.

Ad 1b.
I tried to use async and await for all setState() occurences, but this leads to timing issues: the adapter keeps retrying to build up the connection. I.e. somehow await does not synchronize how I would expect.

@git-kick
Copy link
Owner Author

Fixed in master branch; will be released with v1.2.4

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working maintenance e.g. requested by ioBroker Checker or Dependabot
Projects
None yet
Development

No branches or pull requests

1 participant