Skip to content

Commit 8dfcd87

Browse files
authored
fix: Unref timers (#12482)
1 parent cffd604 commit 8dfcd87

25 files changed

Lines changed: 81 additions & 90 deletions

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.4.11/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.5.0/schema.json",
33
"vcs": {
44
"enabled": true,
55
"clientKind": "git",

src/converters/fromZigbee.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ export const occupancy_with_timeout: Fz.Converter<"msOccupancySensing", undefine
596596
if (timeout !== 0) {
597597
const timer = setTimeout(() => {
598598
publish({occupancy: false});
599-
}, timeout * 1000);
599+
}, timeout * 1000).unref();
600600

601601
globalStore.putValue(msg.endpoint, "occupancy_timer", timer);
602602
}
@@ -1099,7 +1099,7 @@ export const ias_vibration_alarm_1_with_timeout: Fz.Converter<"ssIasZone", undef
10991099
if (timeout !== 0) {
11001100
const timer = setTimeout(() => {
11011101
publish({vibration: false});
1102-
}, timeout * 1000);
1102+
}, timeout * 1000).unref();
11031103

11041104
globalStore.getValue(msg.endpoint, "timers").push(timer);
11051105
}
@@ -1293,7 +1293,7 @@ export const ias_occupancy_alarm_1_with_timeout: Fz.Converter<"ssIasZone", undef
12931293
clearTimeout(globalStore.getValue(msg.endpoint, "timer"));
12941294

12951295
if (timeout !== 0) {
1296-
const timer = setTimeout(() => publish({occupancy: false}), timeout * 1000);
1296+
const timer = setTimeout(() => publish({occupancy: false}), timeout * 1000).unref();
12971297
globalStore.putValue(msg.endpoint, "timer", timer);
12981298
}
12991299

@@ -1470,7 +1470,7 @@ export const command_move: Fz.Converter<"genLevelCtrl", undefined, ["commandMove
14701470
const property = postfixWithEndpointName("brightness", msg, model, meta);
14711471
const deltaProperty = postfixWithEndpointName("action_brightness_delta", msg, model, meta);
14721472
publish({[property]: brightness, [deltaProperty]: delta});
1473-
}, intervalOpts);
1473+
}, intervalOpts).unref();
14741474

14751475
globalStore.putValue(msg.endpoint, "simulated_brightness_timer", timer);
14761476
}
@@ -1911,7 +1911,7 @@ export const checkin_presence: Fz.Converter<"genPollCtrl", undefined, ["commandC
19111911
// Stop existing timer because presence is detected and set a new one.
19121912
clearTimeout(globalStore.getValue(msg.endpoint, "timer"));
19131913

1914-
const timer = setTimeout(() => publish({presence: false}), timeout * 1000);
1914+
const timer = setTimeout(() => publish({presence: false}), timeout * 1000).unref();
19151915
globalStore.putValue(msg.endpoint, "timer", timer);
19161916

19171917
return {presence: true};

src/devices/candeo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const fzLocal = {
134134
}
135135
}
136136
globalStore.putValue(endpoint, "button_click_count", 0);
137-
}, timeout);
137+
}, timeout).unref();
138138
globalStore.putValue(endpoint, "timer", timer);
139139
},
140140
} satisfies Fz.Converter<"genOnOff", undefined, ["attributeReport", "readResponse"]>,

src/devices/echostar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const fzLocal = {
1818
}
1919

2020
const lookup: KeyValueAny = {commandOn: "bell1", commandOff: "bell2"};
21-
const timer = setTimeout(() => globalStore.getValue(msg.endpoint, "action").pop(), timeout * 1000);
21+
const timer = setTimeout(() => globalStore.getValue(msg.endpoint, "action").pop(), timeout * 1000).unref();
2222

2323
const list = globalStore.getValue(msg.endpoint, "action");
2424
if (list.length === 0 || list.length > 4) {

src/devices/fireangel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const fzLocal = {
1818
if (lastTestTimeout) clearTimeout(lastTestTimeout);
1919

2020
if (testActive) {
21-
const timeout = setTimeout(() => publish({test: false}), 8000);
21+
const timeout = setTimeout(() => publish({test: false}), 8000).unref();
2222
globalStore.putValue(msg.endpoint, "lastTestTimeout", timeout);
2323
}
2424

src/devices/javis.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const fzLocal = {
3535
const data = utf8FromStr(msg.data["16896"] as string);
3636

3737
clearTimeout(globalStore.getValue(msg.endpoint, "timer"));
38-
const timer = setTimeout(() => publish({action: "lock", state: "LOCK"}), 2 * 1000);
38+
const timer = setTimeout(() => publish({action: "lock", state: "LOCK"}), 2 * 1000).unref();
3939
globalStore.putValue(msg.endpoint, "timer", timer);
4040

4141
return {

src/devices/kmpcil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function handleKmpcilPresence(
4545
const timeout = Number(mode ? timeoutDc : timeoutBattery);
4646
// Stop existing timer because motion is detected and set a new one.
4747
clearTimeout(globalStore.getValue(msg.endpoint, "timer"));
48-
const timer = setTimeout(() => publish({presence: false}), timeout * 1000);
48+
const timer = setTimeout(() => publish({presence: false}), timeout * 1000).unref();
4949
globalStore.putValue(msg.endpoint, "timer", timer);
5050

5151
return {presence: true};

src/devices/lidl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ const valueConverterLocal = {
122122
time_left: timeLeftInMinutes,
123123
});
124124
}
125-
}, 60 * 1000);
125+
}, 60 * 1000).unref();
126126
}
127127
// initial reporting
128128
result.time_left = ts.timer;

src/devices/mindy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const tzLocal = {
6666
} catch {
6767
/* Do nothing */
6868
}
69-
setTimeout(() => retryRead(attempts - 1), 10000);
69+
setTimeout(() => retryRead(attempts - 1), 10000).unref();
7070
}
7171
};
7272

src/devices/nous.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const definitions: DefinitionWithExtend[] = [
5353

5454
setTimeout(() => {
5555
publish({warming_up: false});
56-
}, 120 * 1000);
56+
}, 120 * 1000).unref();
5757
return true;
5858
},
5959
},

0 commit comments

Comments
 (0)