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

Improved handling of timing functions for fetching train data #15

Merged
merged 1 commit into from
Sep 22, 2020

Conversation

mattdy
Copy link
Contributor

@mattdy mattdy commented May 17, 2020

I've been having problems where this module becomes stuck at a particular time and no longer tries to fetch any updates. I narrowed this down to the case where a request for GET_TRAININFO was sent, but due to my internet connectivity being down at the time, this request would never get handled and answered with a TRAIN_DATA reply. Because the next call to scheduleUpdate() only occurred after the reply is handled, this would cause the module to get stuck and never update.

This PR replaces the scheduleUpdate() functionality with an initial setTimeout() call in start() (delaying the first request according to the this.config.initialLoadDelay parameter), and then fetching data with setInterval() at the appropriate timing from this.config.updateInterval.

As this loop doesn't rely on the data actually being received and processed, it will mean any dropped requests do not result in the module becoming frozen.

@mattdy mattdy mentioned this pull request May 17, 2020
@nwootton nwootton merged commit 35e891f into nwootton:master Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants