@nxtedition/lib 23.17.18 → 23.17.19

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 (3) hide show
  1. package/app.js +1 -2
  2. package/package.json +1 -1
  3. package/yield.js +12 -8
package/app.js CHANGED
@@ -38,7 +38,6 @@ import { isTimeBetween } from './time.js'
38
38
  import makeUnderPressure from './under-pressure.js'
39
39
  import undici from '@nxtedition/undici'
40
40
  import { isPrimary } from 'node:cluster'
41
- import { doYield } from './yield.js'
42
41
 
43
42
  export function makeApp(appConfig, onTerminate) {
44
43
  let ds
@@ -398,7 +397,7 @@ export function makeApp(appConfig, onTerminate) {
398
397
  {
399
398
  userAgent,
400
399
  url: isProduction ? 'ws://deepstream:6020/deepstream' : 'ws://127.0.0.1:6020/deepstream',
401
- schedule: (fn) => doYield(fn),
400
+ schedule: (fn) => setImmediate(fn),
402
401
  },
403
402
  appConfig.deepstream,
404
403
  config.deepstream,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "23.17.18",
3
+ "version": "23.17.19",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
package/yield.js CHANGED
@@ -21,23 +21,23 @@ export function shouldYield() {
21
21
  return yieldActive
22
22
  }
23
23
 
24
- export function maybeYield(callback) {
24
+ export function maybeYield(callback, opaque) {
25
25
  if (callback != null && typeof callback !== 'function') {
26
26
  throw new TypeError('callback must be a function')
27
27
  }
28
28
 
29
29
  if (shouldYield()) {
30
- return doYield(callback)
30
+ return doYield(callback, opaque)
31
31
  }
32
32
 
33
33
  if (callback != null) {
34
- callback(null)
34
+ callback(null, opaque)
35
35
  }
36
36
 
37
37
  return null
38
38
  }
39
39
 
40
- export function doYield(callback) {
40
+ export function doYield(callback, opaque) {
41
41
  if (callback != null && typeof callback !== 'function') {
42
42
  throw new TypeError('callback must be a function')
43
43
  }
@@ -48,12 +48,12 @@ export function doYield(callback) {
48
48
  }
49
49
 
50
50
  if (callback != null) {
51
- yieldQueue.push(callback)
51
+ yieldQueue.push(callback, opaque)
52
52
  return null
53
53
  }
54
54
 
55
55
  return new Promise((resolve) => {
56
- yieldQueue.push(resolve)
56
+ yieldQueue.push(resolve, opaque)
57
57
  })
58
58
  }
59
59
 
@@ -68,7 +68,11 @@ function dispatchYield() {
68
68
  yieldQueue[yieldIndex] = null
69
69
  yieldIndex += 1
70
70
 
71
- resolve(null)
71
+ const opaque = yieldQueue[yieldIndex]
72
+ yieldQueue[yieldIndex] = null
73
+ yieldIndex += 1
74
+
75
+ resolve(opaque)
72
76
 
73
77
  if (shouldYield()) {
74
78
  break
@@ -80,7 +84,7 @@ function dispatchYield() {
80
84
  yieldQueue.splice(0)
81
85
  yieldIndex = 0
82
86
  } else {
83
- if (yieldIndex > 4096) {
87
+ if (yieldIndex > 16 * 1024) {
84
88
  yieldQueue.splice(0, yieldIndex)
85
89
  yieldIndex = 0
86
90
  }