fix: config "block" was not applied immediately with new values

Massimo Melina committed Jul 15, 2026 at 15:01 UTC 8cb8e7a452f47ac567fad46401fd4e96473e1b99
1 file changed +4 -3
src/block.ts
+4 -3
@@ -15,9 +15,10 @@ export const block = defineConfig('block', [] as BlockingRule[], rules => {
15 rule.expire &&= new Date(rule.expire)
16 return !rule.disabled && (rule.expire || now) >= now && makeNetMatcher(rule.ip)
17 }))
18 - // reapply new block to existing connections
19 - for (const { socket, ip } of getConnections())
20 - applyBlock(socket, ip)
18 + setTimeout(() => { // wait until defineConfig has stored the newly compiled rules, because applyBlock uses isBlocked, that uses block.compiled
19 + for (const { socket, ip } of getConnections()) // reapply new block to existing connections
20 + applyBlock(socket, ip)
21 + })
22 return ret
23 })
24