Skip to content

fix: pass the node to checkRpcLock instead of an undefined self - #18

Merged
frankmeds merged 2 commits into
mainfrom
fix/rpc-lock-self-reference
Nov 27, 2026
Merged

frankmeds merged 2 commits into
mainfrom
fix/rpc-lock-self-reference

Conversation

@frankmeds

Copy link
Copy Markdown

Problem

checkRpcLock() is a module-level function, yet when the RPC lock times out it resets the chain filter state through self, which only exists inside Node methods. Whenever the monitored node is slow enough to keep the lock past RPC_LOCK_TIMEOUT (10 s), the agent throws ReferenceError: self is not defined at lib/node.js:171, exits 1 and PM2 restarts it.

On zq2-mainnet-api-ase1-0 that is 2035 restarts between 2026-11-20 and 2026-11-27, peaking at 758 and 783 per day during the 11-24/25 API slowdown.

Fix

Pass the Node instance into checkRpcLock(node) at all four call sites.

Tests

  • test/rpc-lock.test.js (npm test, built-in node:test, no new dependency) loads lib/node.js in a vm context with stubbed dependencies and a fake clock, engages the lock and lets it time out. Before the fix it fails with the production ReferenceError; after the fix it passes and the node's chain filter state is reset.

Francesco Medas added 2 commits November 27, 2026 15:11
checkRpcLock is a module-level function, yet it reset the chain filter
state through 'self', which only exists inside Node methods. Whenever a
slow node kept the RPC lock past RPC_LOCK_TIMEOUT, the agent threw
'ReferenceError: self is not defined', exited 1 and PM2 restarted it:
2035 restarts on zq2-mainnet-api-ase1-0 between 2026-11-20 and 11-27.

Adds a node:test regression test and an npm test script.
v2 of ci-dockerized-app-build-push pulls configure-aws-profile@main,
which DEVOPS-228 (cubedro#84) removed, so every image build fails before it
starts. v4 takes the same inputs.
@frankmeds
frankmeds merged commit 6a769a3 into main Nov 27, 2026
1 check failed
@frankmeds
frankmeds deleted the fix/rpc-lock-self-reference branch November 27, 2026 11:33
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