Closed dahjelle closed 6 years ago
FWIW, this occurs in Node 0.10.36, 0.10.39, and 0.12.6, as well as in io.js 2.3.3 with the same symptoms and "workaround".
also happens on 0.12.7 with exact same error and file font.js
, seeing error in 4.1.0 as well
I think what happens is this:
output
output
has to bufferoutput
's bufferpush
things to output, but push
bypasses its bufferlikely fix is to use output.write
instead of output.push
.
I've been trying to run
browserify
andbrfs
onpdfkit
, but running into the issue at substack/brfs#23. Digging through things a bit, it seems that there is an odd timing issue with streams such that replacing(from index.js) with
seems to fix the issue in this case, though it certainly isn't a very satisfying fix.
More background:
I'm testing by running
Without the fix, I get the error:
This seems to happen because one of the
fs.readFileSync
replacements gets cut off in the middle in the first pass (i.e. the pass as specified inpdfkit
'spackage.json
), and so the second pass (i.e. specified in the command line) doesn't have valid syntax to parse any longer.It is as if the
output
stream continues before thes.stream
is fully piped into it. No idea exactly why thesetTimeout
fixes it, or if it fixes all cases, but it sure seems to fix this one.