Skip to content

Commit 5793a26

Browse files
committed
Revert "fix: ignore 'DB closed' rejections during adapter shutdown"
This reverts commit 757a564.
1 parent 757a564 commit 5793a26

1 file changed

Lines changed: 2 additions & 23 deletions

File tree

main.js

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,6 @@ class VwWeconnect extends utils.Adapter {
347347
// not entitled) do NOT trigger restart — those don't self-heal,
348348
// the user must fix the config.
349349
if (this.config.type === "id") {
350-
// Adapter is shutting down — the rejection is just async work
351-
// that lost its DB connection mid-flight. No restart, no log
352-
// noise, the controller will start the next instance itself.
353-
if (this._unloaded || /db closed/i.test(msg)) {
354-
return;
355-
}
356350
if (/login failed|password_invalid|email_invalid|account.*(locked|disabled)|not entitled/i.test(msg)) {
357351
this.log.error(
358352
"VW ID: EU Data Act login refused. Adapter staying down until " +
@@ -7351,10 +7345,6 @@ class VwWeconnect extends utils.Adapter {
73517345
this.log.debug(`EU Data Act: ${vin} no datasets emitted yet (data request just activated?)`);
73527346
return;
73537347
}
7354-
// Adapter shutdown lost the DB mid-write. Not a real failure, no log.
7355-
if (this._unloaded || /db closed/i.test(msg)) {
7356-
return;
7357-
}
73587348
// 5xx that survived the lib's single re-login retry — the portal is
73597349
// genuinely degraded (Adobe AEM outage / backend hiccup) or our 500+HTML
73607350
// heuristic was a false-positive (the body sometimes IS HTML for non-
@@ -7517,9 +7507,7 @@ class VwWeconnect extends utils.Adapter {
75177507
if (this.tibberInterval) clearInterval(this.tibberInterval);
75187508
this.tibberInterval = setInterval(() => {
75197509
this.pollTibber().catch((err) => {
7520-
const m = (err && err.message) || String(err);
7521-
if (this._unloaded || /db closed/i.test(m)) return;
7522-
this.log.error(`Tibber poll failed: ${m}`);
7510+
this.log.error(`Tibber poll failed: ${err.message || err}`);
75237511
});
75247512
}, minutes * 60 * 1000);
75257513

@@ -7538,12 +7526,10 @@ class VwWeconnect extends utils.Adapter {
75387526
// restart picks up newly linked vehicles. Avoids N+1 listHomes/
75397527
// listDevices per poll cycle.
75407528
for (const dev of this.tibberDevices) {
7541-
if (this._unloaded) return;
75427529
let detail;
75437530
try {
75447531
detail = await this.tibberClient.getDevice(dev.homeId, dev.id);
75457532
} catch (err) {
7546-
if (this._unloaded) return;
75477533
this.log.warn(`Tibber: getDevice(${dev.id}) failed: ${err.message || err}`);
75487534
continue;
75497535
}
@@ -7561,20 +7547,13 @@ class VwWeconnect extends utils.Adapter {
75617547
`plug=${normalized.plugStatus} charging=${normalized.chargingStatus}`,
75627548
);
75637549
} catch (err) {
7564-
const m = (err && err.message) || String(err);
7565-
if (this._unloaded || /db closed/i.test(m)) return;
7566-
this.log.warn(`Tibber: state write failed for ${vin}: ${m}`);
7550+
this.log.warn(`Tibber: state write failed for ${vin}: ${err.message || err}`);
75677551
}
75687552
}
75697553
}
75707554

75717555
onUnload(callback) {
75727556
try {
7573-
// Mark the adapter as shutting down so any in-flight async work
7574-
// (EU Data Act / Tibber polls, json2iob writes) can recognise that
7575-
// a "DB closed" error from setStateAsync isn't a real failure and
7576-
// bail without scheduling a restart.
7577-
this._unloaded = true;
75787557
this.setState("info.connection", false, true);
75797558
this.log.info("cleaned everything up...");
75807559
clearInterval(this.refreshTokenInterval);

0 commit comments

Comments
 (0)