Skip to content

Commit d01f5d3

Browse files
authored
Merge pull request #5 from ZerozAndOnes/comment-fix
Comments fix
2 parents 24e8dfb + b2db0df commit d01f5d3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/pdf.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ PDF.prototype.exec = function PdfExec (callback) {
120120
if (code === null) kill(child, onData, onError)
121121

122122
// Since code has a truthy/falsy value of either 0 or 1, check for existence first.
123-
// Ignore if code has a value of 0 since that means PhantomJS has executed and exited successfully.
124123
// Also, as per your script and standards, having a code value of 1 means one can always assume that
125124
// an error occured.
126125
if (((typeof code !== 'undefined' && code !== null) && code !== 0) || err || (code === 0 && !data)) {
@@ -153,6 +152,9 @@ PDF.prototype.exec = function PdfExec (callback) {
153152

154153
// An exit event is most likely an error because we didn't get any data at this point
155154
child.on('close', respond)
155+
// According to child process documentation (https://nodejs.org/docs/latest-v14.x/api/child_process.html#child_process_event_exit),
156+
// exit event can fire before stdio is closed. Thus, it's probably not a good idea to subscribe to exit event at all.
157+
// on('close') above should be sufficient
156158
// child.on('exit', respond)
157159

158160
var config = JSON.stringify({html: this.html, options: this.options})

0 commit comments

Comments
 (0)