question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error write PIPE in AWS using buffer

See original GitHub issue

Hey guys,

I having this error when i get the buffer of content of pdf and save in S3.

The error:

errors: {error: {message: "write EPIPE", name: "Error",…}}
error: {message: "write EPIPE", name: "Error",…}
frames: [{file: "internal/stream_base_commons.js", filePath: "internal/stream_base_commons.js",…},…]
0: {file: "internal/stream_base_commons.js", filePath: "internal/stream_base_commons.js",…}
1: {file: "internal/stream_base_commons.js", filePath: "internal/stream_base_commons.js",…}
2: {file: "net.js", filePath: "net.js", method: "Socket._writeGeneric", line: 776, column: 11,…}
3: {file: "net.js", filePath: "net.js", method: "Socket._write", line: 788, column: 8, context: {},…}
4: {file: "_stream_writable.js", filePath: "_stream_writable.js", method: "doWrite", line: 435,…}
5: {file: "_stream_writable.js", filePath: "_stream_writable.js", method: "writeOrBuffer", line: 419,…}
6: {file: "_stream_writable.js", filePath: "_stream_writable.js", method: "Socket.Writable.write",…}
7: {file: "node_modules/html-pdf/lib/pdf.js",…}
8: {file: "node_modules/html-pdf/lib/pdf.js",…}
9: {file: "src/app/services/ClienteService.ts",…}
10: {file: "src/app/services/ClienteService.ts",…}
11: {file: "internal/process/task_queues.js", filePath: "internal/process/task_queues.js",…}
12: {file: "src/app/controllers/ClienteController.ts",…}
message: "write EPIPE"
name: "Error"

How i doing the generate PDF

let html = fs.readFileSync('contrato.html', 'utf8');

return new Promise((resolve, reject) => {
  pdf.create(html).toBuffer(async function(err, buffer) {
    const saveS3 = await salvaS3(buffer, dados.documento);

    if (saveS3.status !== 200) {
      resolve({
        status: 400,
        data: 'Erro'
      });
    }

    resolve({
      status: 200
    });
  });
});

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:10

github_iconTop GitHub Comments

2reactions
JuanM04commented, Aug 3, 2020

Have you tried adding phantomPath?

pdf.create(html, {
  phantomPath: path.resolve(
    process.cwd(),
    "node_modules/phantomjs-prebuilt/bin/phantomjs"
  ),
})
0reactions
fg0611commented, Sep 15, 2022

So I believe that write EPIPE errors usually mean that the writing failed because the receiving end closed the connection. Which bit of your code is on line 53 in app.js?

Thank you. I’ve solved it. Your suggestion is valid only if phantomjs prebuild is installed; After the correct phantompath is configured, everything is normal; Although a “referenceerror: can’t find variable: $” error occurred later, I removed the script through regular expressions and everything went back to normal.

Hi, I think I’m having a very similar issue. I’m not an experienced dev, could you please share the steps you did to fix it¿?

This is my error, i’m using pdf-creator- node which uses phantom.js

events.js:292 throw er; // Unhandled ‘error’ event ^

Error: write EPIPE at afterWriteDispatched (internal/stream_base_commons.js:156:25) at writeGeneric (internal/stream_base_commons.js:147:3) at Socket._writeGeneric (net.js:785:11) at Socket._write (net.js:797:8) at writeOrBuffer (internal/streams/writable.js:358:12) at Socket.Writable.write (internal/streams/writable.js:303:10) at PDF.PdfExec [as exec] (/app/node_modules/html-pdf/lib/pdf.js:156:15) at PDF.PdfToFile [as toFile] (/app/node_modules/html-pdf/lib/pdf.js:85:8) at /app/node_modules/pdf-creator-node/index.js:69:20 at new Promise (<anonymous>) Emitted ‘error’ event on Socket instance at: at emitErrorNT (internal/streams/destroy.js:106:8) at emitErrorCloseNT (internal/streams/destroy.js:74:3) at processTicksAndRejections (internal/process/task_queues.js:80:21) { errno: -32, code: ‘EPIPE’, syscall: ‘write’ }

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js Error: write after end - AWS Polly - Stack Overflow
I am trying to use AWS Polly for speech synthesis in my node.js app. When I run the speak(text) function for the first...
Read more >
Can not pass PassThrough stream to send object · Issue #1920
Describe the bug There is no possibility to pass stream as type PassThrough to the Body.
Read more >
Resolve errors uploading data to or downloading data ... - AWS
First, follow the steps below to run the SELECT INTO OUTFILE S3 or LOAD DATA FROM S3 commands using Amazon Aurora. If you...
Read more >
Amazon Kinesis Data Firehose FAQs - Streaming Data Pipeline
If “all documents” mode is used, Amazon Kinesis Data Firehose concatenates multiple incoming records based on buffering configuration of your delivery stream, ...
Read more >
Troubleshooting Amazon Kinesis Data Firehose
This happens if you take DynamoDB data that includes the Set type, stream it through Lambda to a delivery stream, and use an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found