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

Error: write EPIPE #55

Closed
aderbas opened this issue Oct 20, 2021 · 16 comments
Closed

Error: write EPIPE #55

aderbas opened this issue Oct 20, 2021 · 16 comments

Comments

@aderbas
Copy link

aderbas commented Oct 20, 2021

Sorry if anyone has had this problem and it has been fixed, I have not found it. I'm trying to run the basic example documentation in the application's Docker container.

Below is my Dockerfile and the error.

# Dockerizing project

FROM node:14-alpine

# Service port
ARG PORT

RUN apk add --no-cache msttcorefonts-installer fontconfig
RUN update-ms-fonts

# Create app directory
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
WORKDIR /home/node/app

# Copy package.json
COPY package*.json ./

# Install dependencies
RUN npm install

# App source
COPY . .

# Change onwner to node user
RUN chown -R node:node /home/node/app

# Chanhe user to node user
USER node

# Bind port
EXPOSE $PORT

CMD ["npm", "start"]

I get this error:

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] (/home/node/app/node_modules/html-pdf/lib/pdf.js:156:15)
    at PDF.PdfToFile [as toFile] (/home/node/app/node_modules/html-pdf/lib/pdf.js:85:8)
    at /home/node/app/node_modules/pdf-creator-node/index.js:42: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'
}

On my machine it works perfectly. Only in the container that generates the error. Anyone to help? Appreciate.

@mhassan1
Copy link

maybe related? nodejs/node#40553

can you try FROM node:14.17-alpine instead?

@aderbas
Copy link
Author

aderbas commented Nov 10, 2021

Thanks for the answer. The same error Error: write EPIPE
=/

@duncanmapes
Copy link

duncanmapes commented Jan 18, 2022

this is happening to me on AWS Lambda too, runtime nodejs14.x

@FZampetti
Copy link

I have the same issue, has anyone fixed it?

@fedotovdev
Copy link

+, has anyone fixed it?

@EstebanCardenas14
Copy link

EstebanCardenas14 commented May 1, 2022

hi, had the same problem
I solved it by declaring the path of the phantomjs.

when i said "project_name" is the name of the project where you develop
i opened the folder node_modules and review if exist the phantomjs folder, opened the most simillar folder "phantomjs-prebuilt", go to bin and in this point you see a file with the name phantomjs, this is the route

const options = {
phantomPath: "../<project_name>/node_modules/phantomjs-prebuilt/bin/phantomjs",
format: "A3",
marginTop: '0.5in',
border: '0.25in',
};

@vitorfreitas
Copy link

For me, moving from node:14-alpine to node:14 solved the problem. Probably the alpine image misses some dependencies required for this library to work.

@hajareshyam
Copy link
Owner

I think this is image related issue. Closing the defect.

@umerchaudhary34
Copy link

I'm having this issue
Can somebody help?

@shashankpandey2012
Copy link

Can anyone help here please

Error occurred 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:787:11)
at Socket._write (net.js:799:8)
at doWrite (_stream_writable.js:403:12)
at writeOrBuffer (_stream_writable.js:387:5)
at Socket.Writable.write (_stream_writable.js:318:11)
at PDF.PdfExec [as exec] (D:\home\site\wwwroot\node_modules\html-pdf\lib\pdf.js:156:15)
at PDF.PdfToBuffer [as toBuffer] (D:\home\site\wwwroot\node_modules\html-pdf\lib\pdf.js:46:8)
at D:\home\site\wwwroot\node_modules\pdf-creator-node\index.js:55:20
at new Promise () {
errno: 'EPIPE',
code: 'EPIPE',
syscall: 'write'
}

I am facing the similar issue. I also tried adding phantomPath in options and pointing correctly to node_modules/phantomjs-prebuilt/bin/phantomjs as suggested but still its not resolved.

Its working perfectly fine in local. However, when deployed in Azure Function App. It breaks.
Node.js Version: 12.19.0

@EstebanCardenas14
Copy link

maybe if you are in nodejs do the command "npm rebuild", sometimes the dependencies are wrong, "rebuild" fixes it

@shashankpandey2012
Copy link

@EstebanCardenas14 Tried as suggested but no luck.

@AYOUBBASIDI
Copy link

I'm facing the same error , It works fine locally , but when I've containerized the app in the docker the error appears.
Has anyone fixed it?

@nelsoncv
Copy link

Im facing same issue on RHEL 8.7, tried set the phantomPath too. No issue running on local macbook.

node:events:491
throw er; // Unhandled 'error' event
^

Error: write EPIPE
at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16)
Emitted 'error' event on Socket instance at:
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -32,
code: 'EPIPE',
syscall: 'write'
}

@nelsoncv
Copy link

Found solution elsewhere on other package that uses phantomjs, the issue is i ran on local and sync node_modules to servers(due to server has no internet access). So a rebuild is required.

npm rebuild phantomjs-prebuilt

@kaljonwal
Copy link

2023-12-07T08:46:54.243Z 676a6d2e-3e26-4198-9829-315d350e1ced ERROR Uncaught Exception {
"errorType": "Error",
"errorMessage": "write EPIPE",
"code": "EPIPE",
"errno": "EPIPE",
"syscall": "write",
"stack": [
"Error: write EPIPE",
" at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:94:16)"
]
}

i'm getting this error
base image
public.ecr.aws/lambda/nodejs:20

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