@nxtedition/timers 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.js +13 -1
  2. package/package.json +2 -2
package/lib/index.js CHANGED
@@ -14,7 +14,16 @@ function dispatch() {
14
14
 
15
15
  if (timer.state > 0 && fastNow >= timer.state) {
16
16
  timer.state = -1
17
- timer.callback(timer.opaque)
17
+ try {
18
+ timer.callback(timer.opaque)
19
+ } catch (err) {
20
+ // Isolate the throw: rethrow asynchronously so dispatch continues.
21
+ // Otherwise fastIndex stays mid-loop and every prior timer gets
22
+ // delayed by a full tick on the next onTimeout().
23
+ queueMicrotask(() => {
24
+ throw err
25
+ })
26
+ }
18
27
  }
19
28
 
20
29
  if (timer.state === -1) {
@@ -38,6 +47,9 @@ function dispatch() {
38
47
 
39
48
  if (fastTimers.length > 0) {
40
49
  refreshTimeout()
50
+ } else if (fastNowTimeout) {
51
+ globalThis.clearTimeout(fastNowTimeout)
52
+ fastNowTimeout = null
41
53
  }
42
54
  }
43
55
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/timers",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -34,5 +34,5 @@
34
34
  "dependencies": {
35
35
  "@nxtedition/yield": "^1.0.16"
36
36
  },
37
- "gitHead": "a29e479679bd053fa37ff8868d47918a8983ee48"
37
+ "gitHead": "472a4cdfd11ff9f1a7dcf8b81599bc1d9270bc90"
38
38
  }