Protocol error (Page.printToPDF): PrintToPDF is not implemented
-
Hello! I have some problem with PrintToPDF!
import request from 'request' const chromium = require('chrome-aws-lambda') const JsReport = require('jsreport') const promisify = require('util').promisify const ncp = promisify(require('ncp')) const path = require('path') const fs = require('fs') const AWS = require('aws-sdk') export default async(_, {event}, ctx) =>{ let jsreport const init = (async () => { jsreport = JsReport({ //configFile: path.join(__dirname, './prod.config.json'), chrome: { launchOptions: { args: chromium.args, defaultViewport: chromium.defaultViewport, executablePath: await chromium.executablePath, headless: chromium.headless, } } }) //await ncp(path.join(__dirname, './data'), './tmp/data') return jsreport.init() })() const body = { 'template': { 'name': 'invoice-main', 'recipe': 'chrome-pdf' }, 'data': { 'data':[ { 'customerNr': 1, 'salutation': 2, 'nameCustomer': 2, 'additive': 2, 'street': 2, 'postCode': 2, 'city': 2 } ] } } //start await init //errr const res = await jsreport.render(body) console.log(res) const response = { statusCode: 200, body: null, } return response }
it*s my code resolver.
After call I have err -{ "errors": [ { "message": "Protocol error (Page.printToPDF): PrintToPDF is not implemented", "path": [ "reports", "test" ], "extensions": { "code": "INTERNAL_SERVER_ERROR", "serviceName": "reports", "query": "mutation{reports{test{body}}}", "variables": {}, "exception": { "message": "Protocol error (Page.printToPDF): PrintToPDF is not implemented", "logged": true, "stacktrace": [ "Error: Protocol error (Page.printToPDF): PrintToPDF is not implemented", " at Promise (/Users/lapinskyi/Documents/api_old/ca-gql-api/services/reports/node_modules/puppeteer/lib/Connection.js:186:56)", " at new Promise (<anonymous>)", " at CDPSession.send (/Users/lapinskyi/Documents/api_old/ca-gql-api/services/reports/node_modules/puppeteer/lib/Connection.js:185:12)", " at Page.pdf (/Users/lapinskyi/Documents/api_old/ca-gql-api/services/reports/node_modules/puppeteer/lib/Page.js:911:39)", " at Page.<anonymous> (/Users/lapinskyi/Documents/api_old/ca-gql-api/services/reports/node_modules/puppeteer/lib/helper.js:145:23)", " at runWithTimeout (/Users/lapinskyi/Documents/api_old/ca-gql-api/services/reports/node_modules/jsreport-chrome-pdf/lib/conversion.js:246:27)", " at process._tickCallback (internal/process/next_tick.js:68:7)" ] } } } ], "data": { "reports": { "test": null } } } what could it be?
-
2020-10-16T08:04:38.793Z - error: Rendering request 2 finished with error in 3902 ms
2020-10-16T08:04:38.793Z - error: Error when processing render request 2 Protocol error (Page.printToPDF): PrintToPDF is not implemented Error: Protocol error (Page.printToPDF): PrintToPDF is not implemented
at Promise (/Users/lapinskyi/Documents/api_old/ca-gql-api/services/reports/node_modules/puppeteer/lib/Connection.js:186:56)
at new Promise (<anonymous>)
at CDPSession.send (/Users/lapinskyi/Documents/api_old/ca-gql-api/services/reports/node_modules/puppeteer/lib/Connection.js:185:12)
at Page.pdf (/Users/lapinskyi/Documents/api_old/ca-gql-api/services/reports/node_modules/puppeteer/lib/Page.js:911:39)
at Page.<anonymous> (/Users/lapinskyi/Documents/api_old/ca-gql-api/services/reports/node_modules/puppeteer/lib/helper.js:145:23)
at runWithTimeout (/Users/lapinskyi/Documents/api_old/ca-gql-api/services/reports/node_modules/jsreport-chrome-pdf/lib/conversion.js:246:27)
at process._tickCallback (internal/process/next_tick.js:68:7)
-
Maybe it's because of the different version of puppeteer bundled in jsreport and chrome you use from
chrome-aws-lambda
package you use.
Please try to follow our aws lambda tutorial https://jsreport.net/learn/aws-lambda-serverless
-
I found a solution
await JsReport({ //configFile: path.join(__dirname, './prod.config.json'), chrome: { launchOptions: { args: chromium.args, defaultViewport: chromium.defaultViewport, executablePath: await chromium.executablePath, headless: true, } },
----> headless: true