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

fix: catch errors in pollBackgroundRSSITimer #5568

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions packages/zwave-js/src/lib/driver/Driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5178,11 +5178,16 @@ ${handlers.length} left`,
// and up to 30s if we recently queried the RSSI
30_000 - (Date.now() - this.lastBackgroundRSSITimestamp),
);
this.pollBackgroundRSSITimer = setTimeout(() => {
this.pollBackgroundRSSITimer = setTimeout(async () => {
// Due to the timeout, the driver might have been destroyed in the meantime
if (!this.ready) return;

this.lastBackgroundRSSITimestamp = Date.now();
void this.controller.getBackgroundRSSI().catch(() => {
try {
await this.controller.getBackgroundRSSI();
} catch {
// ignore errors
});
}
}, timeout).unref();
} else {
clearTimeout(this.pollBackgroundRSSITimer);
Expand Down