错误:使用html-pdf NPM时在Cloud Run上编写EPIPE [英] Error: write EPIPE on Cloud Run while using html-pdf NPM

查看:123
本文介绍了错误:使用html-pdf NPM时在Cloud Run上编写EPIPE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里,我试图将HTML转换为PDF,并使用html-pdf npm( https://www.npmjs.com/package/html-pdf ).该代码在本地运行良好,并在Google Cloud Run上出现问题.

Here I was trying to convert HTML to PDF and used html-pdf npm (https://www.npmjs.com/package/html-pdf)). The code was running fine on local and got an issue over google cloud run.

Error: write EPIPE at afterWriteDispatched (internal/stream_base_commons.js:154:25) at writeGeneric (internal/stream_base_commons.js:145:3) at Socket._writeGeneric (net.js:786:11) at Socket._write (net.js:798: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] (/usr/src/app/node_modules/html-pdf/lib/pdf.js:141:15) at PDF.PdfToBuffer [as toBuffer] (/usr/src/app/node_modules/html-pdf/lib/pdf.js:44:8) at utilities.createPDF (/usr/src/app/routes/lib/utilities.js:810:31)

Emitted 'error' event on Socket instance at:

 at errorOrDestroy (internal/streams/destroy.js:108:12)

 at onwriteError (_stream_writable.js:418:5)

 at onwrite (_stream_writable.js:445:5)

 at internal/streams/destroy.js:50:7

 at Socket._destroy (net.js:679:5)

 at Socket.destroy (internal/streams/destroy.js:38:8)

 at afterWriteDispatched (internal/stream_base_commons.js:154:17)

 at writeGeneric (internal/stream_base_commons.js:145:3)

 at Socket._writeGeneric (net.js:786:11)

 at Socket._write (net.js:798:8) {

 errno: 'EPIPE',

 code: 'EPIPE',

 syscall: 'write'

这是使用的JS代码,在 pdf.create 函数上发生了错误:-

This the JS code used, error occurred on pdf.create function:-

var pdf = require('html-pdf');
var html = <HTML code>;
var options = { 
    format: 'A4',
    border: {
        "top": "20px",            
        "right": "15px",
        "bottom": "15px",
        "left": "12.5px"
      },
 };
 
pdf.create(html, options).toBuffer(function(err, buffer){
  console.log('This is a buffer:', Buffer.isBuffer(buffer));
    console.log(buffer);

推荐答案

我与NPM创建者进行了讨论,并讨论了npm在其中使用套接字编程的情况.因此,在进一步研究中发现,Cloud Run不支持内部Socket调用,这是无法正常运行的正确原因.

I had a discussion with NPM creator and discussed that npm uses socket programming in it. So on further research found the Cloud Run doesn't support internal Socket calling, which is the correct reason this is not working.

这篇关于错误:使用html-pdf NPM时在Cloud Run上编写EPIPE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆