WebSocketProvider vs HttpProvider: Real‑Time Events vs Stateless Stability
In web3.js v1.5.x the WebSocketProvider keeps event listeners after an unsubscribe call, leading to incremental memory growth when newBlockHeaders subscriptions are created repeatedly. The documented fix is to call subscription.unsubscribe() followed by provider.disconnect() before process exit, which releases listeners and closes the socket. However, the de