After first request to jsreport.init() server on lambda, jsreport.init() - not worked. All time I waiting answer from jsreport and in end I have answer "Endpoint request timed out". And I have conclusion - jsreport.init() not worked. problem only with starting jsreport.init() after first request.
How fix that it?
Posts made by lapinskyi98
-
Problems with jsreport on serverless (lambda)
-
Stop started process jsreport.init() in serverless server (lambda)
How i can stopped process from jsreport.init()? my code for starting report:
"const jsReport = await JsReport(config).init()"
I want restart jsreport.init() after something err -
Err with Timeout for file system
I have err in my serverless server and
this error appears 1 time in 10
: "Unable to load planned schedules Error: Timeout during waiting for file system, try it again later."
How fix that it?! -
"Error: Error when loading extension html-to-xlsx@2.8.0",
What is it?
"Error: Error when loading extension html-to-xlsx@2.8.0", "Error: Cannot find module 'dayjs'", " at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)", " at Function.Module._load (internal/modules/cjs/loader.js:562:25)", " at Module.require (internal/modules/cjs/loader.js:692:17)", " at require (internal/modules/cjs/helpers.js:25:18)", " at Object.<anonymous> (/opt/nodejs/node_modules/jsreport-exceljs/lib/csv/csv.js:4:15)", " at Module._compile (internal/modules/cjs/loader.js:778:30)", " at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)", " at Module.load (internal/modules/cjs/loader.js:653:32)", " at tryModuleLoad (internal/modules/cjs/loader.js:593:12)", " at Function.Module._load (internal/modules/cjs/loader.js:585:3)", " at Module.require (internal/modules/cjs/loader.js:692:17)", " at require (internal/modules/cjs/helpers.js:25:18)", " at Object.<anonymous> (/opt/nodejs/node_modules/jsreport-exceljs/lib/doc/workbook.js:6:13)", " at Module._compile (internal/modules/cjs/loader.js:778:30)", " at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)", " at Module.load (internal/modules/cjs/loader.js:653:32)", " at tryModuleLoad (internal/modules/cjs/loader.js:593:12)", " at Function.Module._load (internal/modules/cjs/loader.js:585:3)", " at Module.require (internal/modules/cjs/loader.js:692:17)", " at require (internal/modules/cjs/helpers.js:25:18)", " at Object.<anonymous> (/opt/nodejs/node_modules/jsreport-exceljs/lib/exceljs.nodejs.js:2:13)", " at Module._compile (internal/modules/cjs/loader.js:778:30)", " at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)", " at Module.load (internal/modules/cjs/loader.js:653:32)", " at tryModuleLoad (internal/modules/cjs/loader.js:593:12)", " at Function.Module._load (internal/modules/cjs/loader.js:585:3)", " at Module.require (internal/modules/cjs/loader.js:692:17)", " at require (internal/modules/cjs/helpers.js:25:18)", " at Object.<anonymous> (/opt/nodejs/node_modules/html-to-xlsx/lib/tableToXlsx.js:4:17)", " at Module._compile (internal/modules/cjs/loader.js:778:30)", " at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)", " at Module.load (internal/modules/cjs/loader.js:653:32)", " at tryModuleLoad (internal/modules/cjs/loader.js:593:12)", " at Function.Module._load (internal/modules/cjs/loader.js:585:3)", " at Object._useOne (/opt/nodejs/node_modules/jsreport-core/lib/extensions/extensionsManager.js:216:15)", " at Object._useMany (/opt/nodejs/node_modules/jsreport-core/lib/extensions/extensionsManager.js:98:20)
My code
const init = (async () => { jsreport = await JsReport({ //configFile: path.join(__dirname, './prod.config.json'), chrome: { launchOptions: { args: chromium.args, defaultViewport: chromium.defaultViewport, executablePath: await chromium.executablePath, headless: chromium.headless, } }, //dev--> 'httpPort': 5488, 'allowLocalFilesAccess': true, 'store': { 'provider': 'fs' }, 'blobStorage': { 'provider': 'fs', 'dataDirectory': '/tmp/storage' }, 'timeout': 60000, 'logger': { 'file': { 'silent': true }, 'error': { 'silent': true } }, 'extensions': { 'authentication': { 'enabled': false }, 'authorization': { 'enabled': false }, 'cli': { 'enabled': false }, 'express': { 'enabled': false }, 'freeze': { 'enabled': false }, 'fs-store': { 'dataDirectory': '/tmp/data' }, 'import-export': { 'enabled': false }, 'public-templates': { 'enabled': false }, 'sample-template': { 'enabled': false }, 'studio': { 'enabled': false }, 'studio-theme-dark': { 'enabled': false }, 'tags': { 'enabled': false }, 'version-control': { 'enabled': false } } //dev<-- }) 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': 3333 } ] } } await init const res = await jsreport.render(body)
my package.json
{ "name": "reports", "version": "1.0.0", "description": "", "scripts": { "start": "sls offline start", "deploy": "sls deploy", "jsreport": "jsreport" }, "dependencies": {}, "jsreport": { "entryPoint": "server.js" }, "devDependencies": { "@apollo/federation": "^0.12.1", "apollo-server-lambda": "^2.10.0", "archiver": "3.0.0", "aws-sdk": "^2.544.0", "chrome-aws-lambda": "2.0.2", "dataloader-sequelize": "^2.0.0", "dateformat": "^3.0.3", "graphql-iso-date": "^3.6.1", "graphql-type-json": "^0.3.1", "ioredis": "^4.14.1", "jsonwebtoken": "^8.5.1", "jsreport": "^2.9.0", "jwk-to-pem": "^2.0.1", "modclean": "^3.0.0-beta.1", "mysql2": "^2.2.5", "ncp": "2.0.0", "request": "^2.88.0", "rimraf": "3.0.1", "sequelize": "^5.19.0", "serverless-offline-direct-lambda": "^0.0.1", "source-map-support": "^0.5.16" }, "author": "", "license": "ISC" }
Our company wants to buy your product! But we simply cannot implement your code ...
By your example, everything works out!
But it is not clear how to deploy it in other cases. -
RE: Lambda deploy "message": "EROFS: read-only file system, mkdir '/var/task/logs'"
ncp(path.join(__dirname, './data'), './tmp/data') ->
tmp for this? -
RE: Lambda deploy "message": "EROFS: read-only file system, mkdir '/var/task/logs'"
Yes
I do it according to the recommendations!
But the error remains. Can you know why this error? -
RE: Protocol error (Page.printToPDF): PrintToPDF is not implemented
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
-
RE: Lambda deploy "message": "EROFS: read-only file system, mkdir '/var/task/logs'"
EROR
[ "Error: EROFS: read-only file system, mkdir '/var/task/logs'", " at Object.mkdirSync (fs.js:757:3)", " at Function.sync (/opt/nodejs/node_modules/mkdirp/index.js:72:13)", " at addTransports (/opt/nodejs/node_modules/jsreport/lib/extendConfig.js:50:12)", " at Reporter.module.exports [as _fnAfterConfigLoaded] (/opt/nodejs/node_modules/jsreport/lib/extendConfig.js:55:3)", " at Reporter._initOptions (/opt/nodejs/node_modules/jsreport-core/lib/reporter.js:389:16)" ]
-
Lambda deploy "message": "EROFS: read-only file system, mkdir '/var/task/logs'"
How to disable LOGS?
My code
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 = await JsReport({ //configFile: path.join(__dirname, './prod.config.json'), chrome: { launchOptions: { args: chromium.args, defaultViewport: chromium.defaultViewport, executablePath: await chromium.executablePath, headless: true, } }, 'store': { 'provider': 'fs' }, 'blobStorage': { 'provider': 'fs' }, 'tasks': { 'allowedModules':'*', 'strategy': 'in-process' }, 'loadConfig': false, logger: { enabled: false, silent: true }, 'studio': { 'enabled': false }, 'allowLocalFilesAccess': false, 'reportTimeout': 60000, 'templatingEngines': { 'strategy': 'http-server' }, 'extensions': { 'express': { 'enabled': false }, 'scripts': { 'strategy': 'http-server' },'studio': { 'requestLogEnabled': false }, }, }) //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': 3333 } ] } } await init const res = await jsreport.render(body) return({ statusCode: 200, body: null, }) }
my package.json
{ "name": "reports", "version": "1.0.0", "description": "", "scripts": { "start": "sls offline start", "deploy": "sls deploy", "jsreport": "jsreport" }, "dependencies": { }, "jsreport": { "entryPoint": "server.js" }, "devDependencies": { "jsreport": "^2.10.0", "puppeteer": "^1.11.0", "aws-sdk": "^2.544.0", "serverless-offline-direct-lambda": "^0.0.1", "@apollo/federation": "^0.12.1", "apollo-server-lambda": "^2.10.0", "archiver": "3.0.0", "chrome-aws-lambda": "2.0.2", "dataloader-sequelize": "^2.0.0", "dateformat": "^3.0.3", "graphql-iso-date": "^3.6.1", "graphql-type-json": "^0.3.1", "ioredis": "^4.14.1", "jsonwebtoken": "^8.5.1", "jwk-to-pem": "^2.0.1", "modclean": "^3.0.0-beta.1", "mysql2": "^2.2.5", "ncp": "2.0.0", "request": "^2.88.0", "rimraf": "3.0.1", "sequelize": "^5.19.0", "source-map-support": "^0.5.16" }, "author": "", "license": "ISC" }
-
RE: Protocol error (Page.printToPDF): PrintToPDF is not implemented
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) -
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?