Skip to content

fix(node): fix five trivial bugs across crypto and inspect - #6129

Merged
jasnell merged 1 commit into
mainfrom
fix/node-trivial-bugs
Feb 23, 2026
Merged

fix(node): fix five trivial bugs across crypto and inspect#6129
jasnell merged 1 commit into
mainfrom
fix/node-trivial-bugs

Conversation

@dknecht

@dknecht dknecht commented Feb 21, 2026

Copy link
Copy Markdown
Member

Summary

Five one-liner bug fixes in the Node.js compatibility layer, plus tests for the two highest-impact ones.

Fixes

  • isRpcWildcardType copy-paste error (internal_inspect.ts:3038): Checked RpcPromise twice, never checked RpcProperty. Inspecting an RpcProperty could trigger proxy traps.

  • randomInt(n, n) infinite loop (crypto_random.ts:246): Guard was min > max instead of min >= max. When min === max, range = 0, causing RAND_MAX % 0 = NaN and an infinite loop.

  • randomFillSync default size ignores offset (crypto_random.ts:90): Default size was maxLength instead of maxLength - offset, writing past buffer bounds when offset is provided without size.

  • publicEncrypt/publicDecrypt error says "privateKey" (crypto_cipher.ts:621,663): Copy-paste from privateEncrypt/privateDecrypt. Changed to 'key'.

  • kState Symbol wrong description (crypto_util.ts:42): Was Symbol('kFinalized'), now Symbol('kState').

Tests

  • randomIntTest: verifies randomInt(5, 5) throws ERR_OUT_OF_RANGE (without fix: hangs forever)
  • randomFillSyncTest: verifies randomFillSync(buf, 4) leaves first 4 bytes untouched (without fix: writes out of bounds)
@dknecht
dknecht requested review from a team as code owners February 21, 2026 14:39
@dknecht
dknecht force-pushed the fix/node-trivial-bugs branch from 566c4fe to 1a4d8d5 Compare February 21, 2026 15:13
@dknecht dknecht changed the title fix(node): fix six trivial bugs across crypto, inspect, and zlib Feb 21, 2026
- Fix isRpcWildcardType checking RpcPromise twice instead of RpcProperty
- Fix randomInt(n, n) infinite loop: reject min >= max, not just min > max
- Fix randomFillSync default size not accounting for offset
- Fix publicEncrypt/publicDecrypt error message saying 'privateKey'
- Fix kState Symbol description ('kFinalized' -> 'kState')
- Add tests for randomInt and randomFillSync edge cases
@dknecht
dknecht force-pushed the fix/node-trivial-bugs branch from 1a4d8d5 to 1ec608d Compare February 21, 2026 15:14
@codspeed-hq

This comment was marked as outdated.

@jasnell
jasnell enabled auto-merge February 21, 2026 16:12
@dom96

dom96 commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

Looks like srs-replica-overload flaked. I re-ran it.

@jasnell
jasnell merged commit 3af1e97 into main Feb 23, 2026
33 of 39 checks passed
@jasnell
jasnell deleted the fix/node-trivial-bugs branch February 23, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants