You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Memory leak: _resolvers entries are never removed when a protocol 3.5 device answers get() with a different sequence number #713
tuyapi 7.7.1 (via node-red-contrib-tuya-smart-device 5.4.0), Node.js 24, Node-RED 4.1, running on a Victron Cerbo GX (ARM, 1 GB RAM)
Device: EV wallbox, Tuya protocol 3.5, polled with get({ schema: true }) every 30 s
What happens
Every get() goes through _send(), which stores this._resolvers[sequenceNo] inside a pRetry operation. The device does answer — the data arrives as a data event — but the response packet carries a different sequenceN, so the packet handler never finds or deletes the resolver. The promise never settles, so the resolver, the pending p-retry RetryOperation and the closures behind it (including buffers of roughly 60 kB each) stay in memory forever.
A heap snapshot after 12.7 h showed 1501 entries in TuyaDevice._resolvers, 1501 RetryOperation objects and about 90 MB of retained ArrayBuffers — almost exactly one entry per poll. Memory grew by about 7 MB/h until the system ran out of memory and restarted every 36–40 h.
Workaround we are using
In _send(), right after the resolver is registered:
With this change memory stays flat (no growth over 12 h). A cleaner fix might be a general timeout in _send(), or matching protocol 3.5 responses to the pending request even when the sequence number differs.
Activity
Apollon77 commentedon Nov 11, 2026
@jowgn You could also do a PR for it :-) That would be great
jowgn commentedon Nov 11, 2026
I will.