Skip to content

Commit 6c2d35f

Browse files
committed
Update plugin-base and sentry
1 parent 68fdbe2 commit 6c2d35f

File tree

7 files changed

+19839
-18983
lines changed

7 files changed

+19839
-18983
lines changed

package-lock.json

Lines changed: 19757 additions & 18916 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/adapter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@iobroker/db-states-redis": "file:../db-states-redis",
1616
"@iobroker/js-controller-common": "file:../common",
1717
"@iobroker/js-controller-common-db": "file:../common-db",
18-
"@iobroker/plugin-base": "~2.0.1",
18+
"@iobroker/plugin-base": "~3.0.1",
1919
"deep-clone": "^3.0.3",
2020
"fs-extra": "^11.3.2",
2121
"jsonwebtoken": "^9.0.0",

packages/adapter/src/lib/adapter/adapter.ts

Lines changed: 72 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,68 +1494,83 @@ export class AdapterClass extends EventEmitter {
14941494
}
14951495
this.terminated = true;
14961496

1497-
this.pluginHandler && this.pluginHandler.destroyAll();
1498-
1499-
if (this._reportInterval) {
1500-
clearInterval(this._reportInterval);
1501-
this._reportInterval = null;
1502-
}
1503-
if (this._restartScheduleJob) {
1504-
this._restartScheduleJob.cancel();
1505-
this._restartScheduleJob = null;
1506-
}
1497+
let shutdownStarted = false;
1498+
const shutdownLogic: () => void = () => {
1499+
if (shutdownStarted) {
1500+
return;
1501+
}
1502+
shutdownStarted = true;
15071503

1508-
let _reason = 'Without reason';
1509-
let _exitCode: number;
1504+
if (this._reportInterval) {
1505+
clearInterval(this._reportInterval);
1506+
this._reportInterval = null;
1507+
}
1508+
if (this._restartScheduleJob) {
1509+
this._restartScheduleJob.cancel();
1510+
this._restartScheduleJob = null;
1511+
}
15101512

1511-
if (typeof reason === 'number') {
1512-
// Only the exit code was passed
1513-
exitCode = reason;
1514-
_reason = 'Without reason';
1515-
} else if (reason && typeof reason === 'string') {
1516-
_reason = reason;
1517-
}
1513+
let _reason = 'Without reason';
1514+
let _exitCode: number;
15181515

1519-
if (typeof exitCode !== 'number') {
1520-
_exitCode = !this._config.isInstall ? EXIT_CODES.ADAPTER_REQUESTED_TERMINATION : EXIT_CODES.NO_ERROR;
1521-
} else {
1522-
_exitCode = exitCode;
1523-
}
1524-
1525-
const isNotCritical =
1526-
_exitCode === EXIT_CODES.ADAPTER_REQUESTED_TERMINATION ||
1527-
_exitCode === EXIT_CODES.START_IMMEDIATELY_AFTER_STOP ||
1528-
_exitCode === EXIT_CODES.NO_ERROR;
1529-
const text = `${this.namespaceLog} Terminated (${Validator.getErrorText(_exitCode)}): ${_reason}`;
1530-
if (isNotCritical) {
1531-
this._logger.info(text);
1532-
} else {
1533-
this._logger.warn(text);
1534-
}
1535-
setTimeout(async () => {
1536-
// give last states some time to get handled
1537-
if (this.#states) {
1538-
try {
1539-
await this.#states.destroy();
1540-
} catch {
1541-
// ignore
1542-
}
1516+
if (typeof reason === 'number') {
1517+
// Only the exit code was passed
1518+
exitCode = reason;
1519+
_reason = 'Without reason';
1520+
} else if (reason && typeof reason === 'string') {
1521+
_reason = reason;
15431522
}
1544-
if (this.#objects) {
1545-
try {
1546-
await this.#objects.destroy();
1547-
} catch {
1548-
//ignore
1549-
}
1523+
1524+
if (typeof exitCode !== 'number') {
1525+
_exitCode = !this._config.isInstall ? EXIT_CODES.ADAPTER_REQUESTED_TERMINATION : EXIT_CODES.NO_ERROR;
1526+
} else {
1527+
_exitCode = exitCode;
15501528
}
1551-
if (this.startedInCompactMode) {
1552-
this.emit('exit', _exitCode, reason);
1553-
this.#states = null;
1554-
this.#objects = null;
1529+
1530+
const isNotCritical =
1531+
_exitCode === EXIT_CODES.ADAPTER_REQUESTED_TERMINATION ||
1532+
_exitCode === EXIT_CODES.START_IMMEDIATELY_AFTER_STOP ||
1533+
_exitCode === EXIT_CODES.NO_ERROR;
1534+
const text = `${this.namespaceLog} Terminated (${Validator.getErrorText(_exitCode)}): ${_reason}`;
1535+
if (isNotCritical) {
1536+
this._logger.info(text);
15551537
} else {
1556-
process.exit(_exitCode);
1538+
this._logger.warn(text);
15571539
}
1558-
}, 500);
1540+
setTimeout(async () => {
1541+
// give last states some time to get handled
1542+
if (this.#states) {
1543+
try {
1544+
await this.#states.destroy();
1545+
} catch {
1546+
// ignore
1547+
}
1548+
}
1549+
if (this.#objects) {
1550+
try {
1551+
await this.#objects.destroy();
1552+
} catch {
1553+
//ignore
1554+
}
1555+
}
1556+
if (this.startedInCompactMode) {
1557+
this.emit('exit', _exitCode, reason);
1558+
this.#states = null;
1559+
this.#objects = null;
1560+
} else {
1561+
process.exit(_exitCode);
1562+
}
1563+
}, 500);
1564+
};
1565+
1566+
if (this.pluginHandler) {
1567+
this.pluginHandler
1568+
.destroyAll()
1569+
.then(() => shutdownLogic())
1570+
.catch(() => shutdownLogic());
1571+
} else {
1572+
shutdownLogic();
1573+
}
15591574
}
15601575

15611576
// external signature
@@ -11071,10 +11086,10 @@ export class AdapterClass extends EventEmitter {
1107111086
thisDir,
1107211087
);
1107311088
this.pluginHandler.setDatabaseForPlugin(pluginName, this.#objects, this.#states);
11074-
this.pluginHandler.initPlugin(pluginName, this.adapterConfig || {});
11089+
await this.pluginHandler.initPlugin(pluginName, this.adapterConfig || {});
1107511090
}
1107611091
} else {
11077-
if (!this.pluginHandler.destroy(pluginName)) {
11092+
if (!(await this.pluginHandler.destroy(pluginName))) {
1107811093
this._logger.info(
1107911094
`${this.namespaceLog} Plugin ${pluginName} could not be disabled. Please restart adapter to disable it.`,
1108011095
);

packages/cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
"dependencies": {
99
"@iobroker/js-controller-common": "file:../common",
1010
"@iobroker/js-controller-common-db": "file:../common-db",
11-
"@iobroker/plugin-base": "~2.0.1",
11+
"@iobroker/plugin-base": "~3.0.1",
1212
"axios": "^1.12.0",
1313
"chokidar": "^3.5.3",
14-
"debug": "^4.3.4",
14+
"debug": "^4.4.3",
1515
"deep-clone": "^3.0.3",
1616
"event-stream": "^4.0.1",
1717
"fs-extra": "^11.3.2",

packages/cli/src/lib/setup/dbConnection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ export async function resetDbConnect(): Promise<void> {
359359
}
360360

361361
if (pluginHandler) {
362-
pluginHandler.destroyAll();
362+
await pluginHandler.destroyAll();
363363
}
364364
}
365365

packages/controller/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
"@iobroker/js-controller-cli": "file:../cli",
2121
"@iobroker/js-controller-common": "file:../common",
2222
"@iobroker/js-controller-common-db": "file:../common-db",
23-
"@iobroker/plugin-base": "~2.0.1",
24-
"@iobroker/plugin-sentry": "~2.0.4",
23+
"@iobroker/plugin-base": "~3.0.1",
24+
"@iobroker/plugin-sentry": "~3.0.0",
2525
"axios": "^1.12.0",
2626
"cron-parser": "^4.9.0",
27-
"debug": "^4.3.4",
27+
"debug": "^4.4.3",
2828
"decache": "^4.6.1",
2929
"deep-clone": "^3.0.3",
3030
"fs-extra": "^11.3.2",

packages/controller/src/main.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -616,10 +616,10 @@ function createStates(onConnect: () => void): void {
616616
controllerDir,
617617
);
618618
pluginHandler.setDatabaseForPlugin(pluginName, objects, states);
619-
pluginHandler.initPlugin(pluginName, ioPackage);
619+
await pluginHandler.initPlugin(pluginName, ioPackage);
620620
}
621621
} else {
622-
if (!pluginHandler.destroy(pluginName)) {
622+
if (!(await pluginHandler.destroy(pluginName))) {
623623
logger.info(
624624
`${hostLogPrefix} Plugin ${pluginName} could not be disabled. Please restart ioBroker to disable it.`,
625625
);
@@ -5141,7 +5141,7 @@ function stop(force?: boolean, callback?: () => void): void {
51415141
}
51425142

51435143
stopInstances(force, async wasForced => {
5144-
pluginHandler.destroyAll();
5144+
await pluginHandler.destroyAll();
51455145
notificationHandler && notificationHandler.storeNotifications();
51465146

51475147
try {

0 commit comments

Comments
 (0)