Forum Bugs

Control protocol and stdin stream

Miquik
Hi all,
I'm not sure if this is a bug, but there is a small annoying problem that I'd like to solve.

I have an express server with an endpoint that generate a PDF from HTML. In this endpoint I receive HTML from client, then build job descriptor and create a child_process (spawn) of prince in "control protocol" mode. Then I pipe stdin and stdout of child_process
In practise I've traslated this repo in nodejs

Everything works like a charm, no problem so far, but there is a small annoying problem. I wrap a job descriptor into a stream and pipe it to stdin (I did not include "end" chunk because i want to convert multiple documents) and I receive this log after conversion
log 11
fin|success
err 20
could not read chunk


As you can see conversion finish successfully (PDF is correcte generated) but after that I receive that error message. If I include "end" chunk in input descriptor that error will dissapear.

I think it's something relate how nodejs manage streams. Probably after sending all data to stdin it send some other byte (may be "null"?) to indicate that stream is complete but this byte is interpreted by prince as new corrupted chunk.

As I said this is not a real problem because PDF are correctly generated but maybe is something it can be managed

Thanks
wezm
I wrap a job descriptor into a stream and pipe it to stdin (I did not include "end" chunk because i want to convert multiple documents) and I receive this log after conversion


It sounds a bit like the stdin stream is being closed after that first job is processed. It will need to remain open across jobs in order to submit another job. It might help if you can share or link to your code for this part of the process.