Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdftk exited with failure code: 1 #31

Closed
raminious opened this issue Nov 27, 2017 · 4 comments
Closed

pdftk exited with failure code: 1 #31

raminious opened this issue Nov 27, 2017 · 4 comments

Comments

@raminious
Copy link
Contributor

Hello,
I have an issue with this module. my code is:

function splitFiles(splits, filepath) {
  return new Promise((resolve, reject) => {
    const writeStream = fs
      .createWriteStream(filepath)
      .on('error', e => reject(e))

    scissors
      .join(...splits)
      .pdfStream()
      .on('error', (e) => reject(e))
      .on('finish', resolve)
      .pipe(writeStream)
  })
}

try {
   await splitFiles(splits, filepath)
} catch(e) {
   console.log(e)
}

the problem is when pdftk can't open one of the files, it kills the server instance instead on throwing a safe error

pdftk: Error: Unable to find file.pdftk:
Error: Failed to open PDF file:
   -
Errors encountered.  No output created.
Done.  Input errors, so no output created.
events.js:182
      throw er; // Unhandled 'error' event
      ^

Error: pdftk exited with failure code: 1
    at ChildProcess.<anonymous> (/opt/node/project/web/node_modules/scissors/scissors.js:586:21)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
[nodemon] app crashed - waiting for file changes before starting...

I can handle this issue by adding stream.on('error', err => console.log(err)) next to line 564

@cboulanger
Copy link
Collaborator

Thank you for your report. Can you provide a pull request with this fix?

cboulanger added a commit that referenced this issue Nov 28, 2017
add a handler function for stream. fixes issue #31
@cboulanger
Copy link
Collaborator

Fixed by 9a0b231

@ThunderBoltEngineer
Copy link

Same issue is happening inside Command.prototype._exec function.

I think you should add error handler there as well.

@cboulanger
Copy link
Collaborator

Can you provide a PR? I am currently not working on scissors, but will be happy to merge fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants