I have a node.js server that freezes during production and it seems to be called by an infinite loop inside a JSONStream. Here's the stack trace captured from a core dump from a frozen server:
1: toString [buffer.js:~392] (this=0x1e28fb6d25c9 <a Buffer>#1#,encoding=0x266ee104121 <undefined>,start=0x266ee104121 <undefined>,end=0x266ee104121 <undefined>)
2: arguments adaptor frame: 0->3
3: write [/home/deploy/node_modules/JSONStream/node_modules/jsonparse/jsonparse.js:136] (this=0x32cc8dd5a999 <a Parser>#2#,buffer=0x32cc8dd5aa49 <a Buffer>#3#)
4: [/home/deploy/node_modules/JSONStream/index.js:~17] (this=0x32cc8dd5ab11 <a Stream>#4#,chunk=0x32cc8dd5aa49 <a Buffer>#3#)
5: write [/home/deploy/node_modules/JSONStream/node_modules/through/index.js:~24] (this=0x32cc8dd5ab11 <a Stream>#4#,data=0x32cc8dd5aa49 <a Buffer>#3#)
6: write [_stream_readable.js:~582] (this=0x266ee106c91 <JS Global Object>#5#,dest=0x32cc8dd5ab11 <a Stream>#4#,i=0,list=0x266ee104101 <null>)
7: flow [_stream_readable.js:592] (this=0x266ee106c91 <JS Global Object>#5#,src=0x32cc8dd5ac69 <an IncomingMessage>#6#)
8: [_stream_readable.js:560] (this=0x266ee106c91 <JS Global Object>#5#)
9: _tickCallback [node.js:415] (this=0x29e7331bb2a1 <a process>#7#)
How can I find the source of this infinite loop?
Unfortunately, the servers work in production and process many thousands of requests, so it is difficult to give any additional context. The primary function of servers is to create outgoing HTTP requests for other services.
It is worth noting that I do not believe that this is caused by a memory leak. Server memory usage remains constant (and low) during these freeze events, while the processor reaches 99%
, , , . console.log setInterval, , .
, / , Infinity ( node.js)
JSONStream 0.7.1 ( jsonparse 0.0.5). JSONStream JSONParse jsonparse. .