comq 0.15.0 → 0.15.1

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.15.1](https://github.com/toa-io/comq/compare/v0.15.0...v0.15.1) (2026-08-02)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * skip end control when reply stream buffer overflows ([654e046](https://github.com/toa-io/comq/commit/654e046bdcbfbbbbbb789e5bb032bc16564221d1)), closes [#control](https://github.com/toa-io/comq/issues/control) [#reply](https://github.com/toa-io/comq/issues/reply)
7
+ * skip end control when reply stream buffer overflows ([#237](https://github.com/toa-io/comq/issues/237)) ([c34d87f](https://github.com/toa-io/comq/commit/c34d87f6d219ce6c8509d989117eadd55a33ca86))
8
+
1
9
  # [0.15.0](https://github.com/toa-io/comq/compare/v0.14.0...v0.15.0) (2026-08-01)
2
10
 
3
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comq",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "ComQ",
5
5
  "author": {
6
6
  "name": "Artem Gurtovoi",
@@ -26,6 +26,8 @@ class ReplyStream extends Readable {
26
26
 
27
27
  #buffered = 0
28
28
 
29
+ #maxBufferSize
30
+
29
31
  /** @type {Map<number, unknown>} */
30
32
  #queue = new Map()
31
33
 
@@ -39,6 +41,7 @@ class ReplyStream extends Readable {
39
41
  this.#emitter = request.emitter
40
42
  this.#correlationId = request.properties.correlationId
41
43
  this.#idleInterval = global['COMQ_TESTING_IDLE_INTERVAL'] || IDLE_INTERVAL
44
+ this.#maxBufferSize = global['COMQ_TESTING_MAX_BUFFER_SIZE'] || MAX_BUFFER_SIZE
42
45
  this.#reply = reply
43
46
 
44
47
  this.#emitter.on(this.#correlationId, this.arrange.bind(this))
@@ -48,7 +51,9 @@ class ReplyStream extends Readable {
48
51
  this._clear()
49
52
  this.push(null)
50
53
 
51
- void this.#reply(this.#control, control.end)
54
+ if (this.#control !== undefined)
55
+ void this.#reply(this.#control, control.end)
56
+
52
57
  super._destroy(error, callback)
53
58
  }
54
59
 
@@ -95,7 +100,11 @@ class ReplyStream extends Readable {
95
100
  }
96
101
 
97
102
  _buffer (payload, properties) {
98
- if (this.#buffered > MAX_BUFFER_SIZE) this.destroy()
103
+ if (this.#buffered > this.#maxBufferSize) {
104
+ this.destroy()
105
+
106
+ return
107
+ }
99
108
 
100
109
  this.#buffered++
101
110
  this.#queue.set(properties.headers.index, { payload, properties })
@@ -0,0 +1,45 @@
1
+ 'use strict'
2
+
3
+ const { EventEmitter } = require('node:events')
4
+ const { once } = require('node:events')
5
+ const { ReplyStream } = require('../source/.io/ReplyStream')
6
+
7
+ /** @type {jest.Mock} */
8
+ let reply
9
+
10
+ /** @type {ReplyStream} */
11
+ let stream
12
+
13
+ beforeEach(() => {
14
+ global.COMQ_TESTING_MAX_BUFFER_SIZE = 3
15
+ global.COMQ_TESTING_IDLE_INTERVAL = 60_000
16
+
17
+ reply = jest.fn().mockResolvedValue(true)
18
+
19
+ const request = {
20
+ emitter: new EventEmitter(),
21
+ properties: { correlationId: 'test-correlation' }
22
+ }
23
+
24
+ stream = new ReplyStream(request, reply)
25
+ })
26
+
27
+ afterEach(() => {
28
+ delete global.COMQ_TESTING_MAX_BUFFER_SIZE
29
+ delete global.COMQ_TESTING_IDLE_INTERVAL
30
+
31
+ stream.destroy()
32
+ })
33
+
34
+ it('should destroy without calling reply when buffer overflows before control.ok', async () => {
35
+ const closed = once(stream, 'close')
36
+
37
+ for (let index = 1; index <= 5; index++) {
38
+ stream.arrange(index, { headers: { index } })
39
+ }
40
+
41
+ await closed
42
+
43
+ expect(stream.destroyed).toBe(true)
44
+ expect(reply).not.toHaveBeenCalled()
45
+ })