Hey Livekit folks. We’ve been trying to track down...
# agents
s
Hey Livekit folks. We’ve been trying to track down the source of a highly noisy (600k+ errors / month) error
Error: ESRCH: no such process, read
with the
@livekit/agents-js
package. The error seems to start triggering after a while and slowly ramps up in volume until we restart our service. We see the same number of errors every minute until something causes the error count to increase and then it stabilizes again. This pattern repeats. We are self hosting and have seen this same error occur since before agents v1.0.15 and still occurs on v1.0.25. Note that in the attached error per minute graph everytime the errors drop back down to 0 is right after a deploy. I have a hunch that the root cause is in the supervised_proc.ts where you are calling
getchildMemoryUsageMB
inside of a
setInterval
. On line 215 there’s a call to
pidusage(pid)
which checks the process data. Since there’s a 5s interval this is most likely a race condition.
pidusage
can throw system errors including
ESRCH
and in the pidusage npm package they say to not wrap calls to
pidusage()
inside of `setInterval`: >
Copy code
// Avoid using setInterval as they could overlap with asynchronous processing
I think at a minimum the call to
this.getChildMemoryUsageMB
needs error handling. Ideally a refactor to not wrap this call with a
setInterval
as well.
l
Sounds like you are on the right track... I don't see any GH issues related to ESRCH, and I don't think this is a known problem. You mention you are self-hosting, does the issue go away if you add error handling to the
getChildMemoryUsageMB
call? I agree a refactor would be best, but that does at least isolate the root cause