-
Notifications
You must be signed in to change notification settings - Fork 544
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 #35
Comments
I didn't have a look at your html yet, but there are some errors that don't get catched in your code. function(err, html) {
if (err) {
next(err);
}
//...
} In a case of an error, your code continues with the execution. To prevent this, you have to return the error like here: function(err, html) {
if (err) {
return next(err);
}
//...
} |
I assume this was a syntax error. So I'm closing this for now. |
Have same issue.
This code working on my local machine (Win8), but on server (Debian) I got this error and server fault..
I check path to file, its like this: local: c:...path_to_project..\engine../public/reports/..filename.pdf Paths like this works correctly in another places (generate images) |
UPDATE: solved my issue after a reboot. Yep, you read that right. 🔫 I don't know if the error is the same, but it surely looks very related to how the interaction with phantomjs is made: I am spawning my Node process (that uses Error: write EPIPE
at exports._errnoException (util.js:746:11)
at Socket._writeGeneric (net.js:690:26)
at Socket._write (net.js:709:8)
at doWrite (_stream_writable.js:301:12)
at writeOrBuffer (_stream_writable.js:288:5)
at Socket.Writable.write (_stream_writable.js:217:11)
at Socket.write (net.js:634:40)
at PDF.module.exports.PDF.exec (C:\Users\fpontillo\AppData\Roaming\npm\node_modules\my-module\node_modules\html-pdf\lib\pdf.js:136:26)
at PDF.module.exports.PDF.toStream (C:\Users\fpontillo\AppData\Roaming\npm\node_modules\my-module\node_modules\html-pdf\lib\pdf.js:66:19)
at Promise.post (C:\Users\fpontillo\AppData\Roaming\npm\node_modules\my-module\node_modules\q\q.js:1161:36)
events.js:85
throw er; // Unhandled 'error' event
^
Error: spawn phantomjs ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
at child_process.js:1144:20
at process._tickCallback (node.js:355:11) The return child.stdin.write(JSON.stringify({
html: this.html,
options: this.options
}) + '\n', 'utf8'); My setup is Windows 8.1 x64, Node 0.12.7 and phantomjs 2.0.0 (manually installed, not via For reference, here's my C# code I am using to launch the PDF generation: var process = new Process {
StartInfo = new ProcessStartInfo {
FileName = "myapp",
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true
}
};
try {
process.Start();
// write the JSON report to the standard input
process.StandardInput.WriteLine(jsonReport);
process.StandardInput.Close();
// wait for exit
process.WaitForExit();
if (process.ExitCode != 0) {
// THIS IS WHERE IT ERRORS
Console.WriteLine(@"{0}", process.StandardError.ReadToEnd());
}
Console.WriteLine(@"stdout: {0}", process.StandardOutput.ReadToEnd());
} catch (Exception ex) {
Console.WriteLine(ex.StackTrace);
} Do you have any idea of what could cause the issue? |
I had the same error
followed by this one
It is caused by phantomjs's executable being of a wrong architecture.
Running npm install on html-pdf should fix this. |
same problem and running npm instal on html-pdf doesn't fix it.. anyone have found how to solve this ? |
sudo apt-get install libfontconfig |
Not sure if this helps but I started encountering this exact same EPIPE issue while attempting to troubleshoot my rendering issue. It was recommended elsewhere to add the following lines to the options but doing so is what causes the EPIPE issue for me. Removing these lines resolves the EPIPE issue. "phantomPath": "./node_modules/phantomjs/bin/phantomjs", |
|
Hi marc I am facing the EPIPE error once i have deployed my app to Amazon EC2 (Ubuntu 14.04.3 LTS). This works totally fine on my dev box, which is running Windows 10. My app is a meteor app and it is deployed to EC2 using mupx. I used to get the EOENT error and following the instructions here and other places, i did execute Here are my config options
Here is my code invoking the pdf creation. (I removed the code that deals with the returned buffer as part of debugging)
FYI: My code had Meteor.bindEnvironment around the callback function, but i removed that while testing to figure out what is causing these errors. This clearly is happening while html-pdf is trying to create the pdf using phantom, phantom is installed on the image, See below Any help in pointing me to the right direction to either fix this or identify the issue is greatly appreciated. Thanks a lot in advance for your time |
I was facing same EPIPE issue while generating pdf @sovanna's "sudo apt-get install libfontconfig" worked for me Thanks Buddy |
for the record, |
I was getting following error while exporting pdf on my centOS system. Error: write EPIPE After running yum install fontconfig , now pdf is generating but its content is not visible. It is a simple html table. Same case is working on my ubuntu system. |
Try adding the following via yum
I have the above 3 in my Dockerfile that I'm using with this module. These seemed to resolve my issues with fonts or styling. |
I was getting the EPIPE error as well with an app running in docker containers on ec2s. In my case, it turned out not to be the fontconfig lib, but rather needing to |
I had the same thing as @kevinbror and got it working by rebuilding phantomjs. (Everything worked fine in my macbook, but when I cloned the my git to Ubuntu, running my node server there was resulting the EPIPE error.) |
are you pushing your |
I am not that novice :-) My 'base project' is templated by swagger-node-express and it's default .gitignore keeps node modules out of git among other artefact files. However, I might have had a really old phantom version on my ubuntu machine from some other project I have been doing previously with angular app's test automation. But I have seen people's repos with node_modules as well as other library stuff so that is a valid concern you raised 👍 |
I had this problem in Docker as well, I was binding the source code into the container as a volume (for easy development). The problem was that I had built the original npm packages on the host and mapped them into the container (it seems that even npm didn't rebuild the needed packages for the container). The solution was similar to @kevinbror except I had to rebuild everything from inside the container with |
I am having the same issue on macOS
tried every possible solution suggested on web. doesn't got any luck. And when i try to convert the HTML from terminal it works fine. :( |
You just have to install |
Hi, I am using html-pdf npm package for my electron app. It was working perfect in both development and production environment. But now after using ASAR to pack my code, it stopped working in production. Gives Error Uncaught Error: write EPIPE The solution mentioned by others i.e. to install libfontconfig is not applicable here since there is not libfontconfig package in npm. Being a nube I expect to be clarified if i failed to understand things from the error msg or from the above discussions. P.S: I am well aware that ASAR pack are read only. So the path for pdf is outside it. But still the same problem. Does html-pdf perform any write operation other then the final write to the file path specified? |
@ishwarrimal any chance you figured out a solution to this issue with electron? Dealing with this now... |
hi @danmckeon, since I would prefer the second approach (using inbuilt tool) but if you want to know more about the first approach please let me know. Hope this helps. |
@ishwarrimal I noticed that tool, but every PDF I create with Chromium (including with the Electron tool) is huge. Did you find a workaround for that? |
“Generating PDF with Electron.js”
https://medium.com/@ishwar.rimal/generating-pdf-with-electron-js-31b59ac93249
…On Tue 17 Apr, 2018, 2:22 PM Tommy Riska, ***@***.***> wrote:
I have the same problem on Windows and cant get html-pdf
<https://www.npmjs.com/package/html-pdf> to work after packing to asar.
Anyone found a workaround on this issue?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#35 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AQre_sOeBANyBy0gpupkCeiC7XVRXh94ks5tpa1NgaJpZM4E2tGm>
.
|
Provide my solution: The problem is on Linux OS If the instruction is invalid, you can install the font according to the version Ubuntu / Debian Centos / Redhat |
@sovanna Thanks man that worked. 👍 |
How can i fix this error on lambda functions ?
My code for pdf creation is below
|
One more solution: Update selinux policy by changing phantomjs file to bin_t type After adding new type to selinux policy you need to update the file permissions Now you need to allow httpd daemon to change its resource limits by setting the boolean Hope it helps ( : |
This will work 100 % -- follow this it worked for me ... https://www.vultr.com/docs/how-to-install-phantomjs-on-ubuntu-16-04 |
same here windows -- though this happened after updating to gulp4. it worked in gulp3.
installing phantomjs-prebuilt globally did not resolve this, hoped it would. update! (windows) |
Indeed, PhantomJS is by default compiled for the platform where PhantomJS addresses this issue on the GitHub README.md here. For me setting the environment variables to:
before running |
Started getting this error after upgrading lambda environment from node 8 to node 10.x. Anyone know how to fix this on AWS lambda? Went back to node 8 |
Same, getting it for node 10 as well on AWS Lambda |
Anyone coming here for AWS lambda node 10 environment, There is a way to add these shared libraries into the lambda layer which would fix the problem |
@Keksike what lambda node js version you are at? |
This answer on explains what to do on aws lambda with node 10 or 12: https://stackoverflow.com/a/56843029/3556874 |
I got this issue running in Docker.
|
Do this In case you are running the app inside docker alpine image, because phantomjs-prebuilt doesn't work on alpine |
use electron build (windows) |
This solution works for me, i ran it on my local then sync files to server. Thanks @kevinbror ! |
Anyone able to figure out the fix? |
Any idea what exactly libfontconfig is used for? |
Found a solution! |
Unfortunately it didn't help me. |
I used Docker to replicate the error that was not possible to replicate on localhost, and I could fix it by adding the following command on my Dockerfile: RUN apk add --no-cache --virtual .build-deps ca-certificates openssl \
&& wget -qO- "https://github.com/dustinblackman/phantomized/releases/download/2.1.1/dockerized-phantomjs.tar.gz" | tar xz -C / \
&& apk del .build-deps I got it from here. |
i am facing same issue but still not able to get the answer |
I'm using nunjucks to render a template into a string, i then try to convert that html to a pdf file however everytime i get this error:
Here is the code i use to create the pdf file:
Here is the HTML string that is generated by nunjucks, not the most readable i know but figured i should post it like it is instead of trying to make it prettier
I've been stuck at this for hours and can't see that im doing anything wrong, any ideas?
The text was updated successfully, but these errors were encountered: