Skip to content

Fix four bugs in ClientSocket, Cursor and Errors#10

Open
JohnSColeman wants to merge 1 commit intoapache:masterfrom
JohnSColeman:master
Open

Fix four bugs in ClientSocket, Cursor and Errors#10
JohnSColeman wants to merge 1 commit intoapache:masterfrom
JohnSColeman:master

Conversation

@JohnSColeman
Copy link
Copy Markdown

Summary

  • ClientSocket: serialize concurrent data event processing — the data handler was async but Node.js does not await async event listeners before firing the next event. Under parallel scan workloads, a second TCP frame could arrive while _processResponse was suspended at await _finalizeResponse, corrupting shared _buffer/_offset state. Fixed by chaining each invocation onto a _processingQueue promise so frames are always processed serially.

  • ClientSocket: fix per-message buffer position tracking — when two complete Ignite messages arrive in a single TCP segment, the while loop read the second message's length from buffer.position (wherever the previous payloadReader left it) rather than from this._offset (the actual start of the second message). Fixed by resetting buffer.position = this._offset at the top of each loop iteration.

  • ClientSocket: fix cursor MessageBuffer aliasing — two cursors created from the same TCP segment were both handed a reference to the same MessageBuffer object. When they concurrently called _read() under Promise.all, they shared the single _position field and interleaved reads at wrong offsets. Fixed by carving a fresh independent MessageBuffer.from(slice) copy for each message's payload before passing it to _finalizeResponse.

  • ClientSocket: silently discard unsolicited server notification frames — Ignite 2.14+ sends topology-change and heartbeat frames with IDs that do not match any pending client request. The original code had no handler for this case; the missing branch caused a crash. Fixed by logging and discarding such frames.

  • Cursor: fix hasMore() returning false on a freshly-opened cursor_hasNext starts as false and _values starts as null, so hasMore() incorrectly returned false before the first _getValues() call. Fixed by also returning true when _buffer != null (the initial scan page is buffered at construction time).

  • Cursor: fix _getValues() null-buffer crash on cursor exhaustion — after the last page was read, _getValues() called _read(null) which crashed with Cannot read properties of null. Fixed with a null-guard that sets _values = null instead.

  • Errors: fix BinaryUtils.getTypeName is not a functionErrors.ts used bare require('./internal/BinaryUtils') which, for an export default class, returns the module namespace object rather than the class. Fixed by adding .default to all three require calls.

Test plan

  • All 103 tests in npm test pass against a live Ignite 2.15 instance
  • Scan query suite (spec/query/ScanQuery.spec.js) passes including multi-page cursor iteration
  • Cache key/value suite passes including put/get of all primitive and complex types

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant