For the last couple of days my colleague (@DanForys) and I have been stumped with a rather unusual error, by which extending our codebase would cause PhantomJS to die; it turns out that the increase in data that Phantom pumped into stdout was causing a buffer overflow.
As explained in Hack Sparrow's post detailing the differences between child_process.spawn and exec, "child_process.exec returns the whole buffer output from the child process. By default the buffer size is set at 200k. If the child process returns anything more than that, you program will crash". child_process.spawn does not have this same restriction, which I imagine is down to how one references standard streams between the two methods. This single change resolved this issue for us.
For the last couple of days my colleague (@DanForys) and I have been stumped with a rather unusual error, by which extending our codebase would cause PhantomJS to die; it turns out that the increase in data that Phantom pumped into
stdout
was causing a buffer overflow.As explained in Hack Sparrow's post detailing the differences between child_process.spawn and exec, "child_process.exec returns the whole buffer output from the child process. By default the buffer size is set at 200k. If the child process returns anything more than that, you program will crash".
child_process.spawn
does not have this same restriction, which I imagine is down to how one references standard streams between the two methods. This single change resolved this issue for us.