Skip to content

Comments

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

Open
dknecht wants to merge 1 commit intomainfrom
fix/node-trivial-bugs
Open

fix(node): fix five trivial bugs across crypto and inspect#6129
dknecht wants to merge 1 commit intomainfrom
fix/node-trivial-bugs

Conversation

@dknecht
Copy link
Member

@dknecht dknecht commented Feb 21, 2026

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 fix(node): fix five trivial bugs across crypto and inspect 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
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.

2 participants