From 69766dbc85acbd9fdb9c5292186f5461f12f433c Mon Sep 17 00:00:00 2001 From: Steven Jones Date: Wed, 26 May 2021 16:05:09 -0700 Subject: [PATCH 1/4] update render defaults --- src/core/render-core.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/render-core.js b/src/core/render-core.js index 7fc6b17b..1ff04e00 100644 --- a/src/core/render-core.js +++ b/src/core/render-core.js @@ -41,9 +41,9 @@ async function getFullPageHeight(page) { async function render(_opts = {}) { const opts = _.merge({ cookies: [], - scrollPage: false, + scrollPage: true, emulateScreenMedia: true, - ignoreHttpsErrors: false, + ignoreHttpsErrors: true, html: null, viewport: { width: 1600, @@ -51,10 +51,11 @@ async function render(_opts = {}) { }, goto: { waitUntil: 'networkidle0', + timout: 120000 }, output: 'pdf', pdf: { - format: 'A4', + format: 'letter', printBackground: true, }, screenshot: { From 914c2b56896329114e7a7596f3c7bdfdcb519a17 Mon Sep 17 00:00:00 2001 From: Steven Jones Date: Wed, 26 May 2021 16:05:45 -0700 Subject: [PATCH 2/4] update scroll timeout from 30s to 120s --- src/core/render-core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/render-core.js b/src/core/render-core.js index 1ff04e00..7a26b820 100644 --- a/src/core/render-core.js +++ b/src/core/render-core.js @@ -231,7 +231,7 @@ async function scrollPage(page) { setTimeout(scrollDown, scrollInterval); } - setTimeout(reject, 30000); + setTimeout(reject, 120000); scrollDown(); }); }); From d78ec09994d5070d5422dbd8c048b6e2a5407ff1 Mon Sep 17 00:00:00 2001 From: Steven Jones Date: Wed, 26 May 2021 16:06:40 -0700 Subject: [PATCH 3/4] truncate url in logging to 300, if > 1024 --- src/core/render-core.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/render-core.js b/src/core/render-core.js index 7a26b820..73fa7636 100644 --- a/src/core/render-core.js +++ b/src/core/render-core.js @@ -243,6 +243,10 @@ function logOpts(opts) { supressedOpts.html = '...'; } + if (opts.url && opts.url.length > 1024) { + supressedOpts.url = opts.url.slice(0, 300); + } + logger.info(`Rendering with opts: ${JSON.stringify(supressedOpts, null, 2)}`); } From 37cb5edc4f82cd2673572395263162dad7235ee0 Mon Sep 17 00:00:00 2001 From: Steven Jones Date: Wed, 26 May 2021 16:07:14 -0700 Subject: [PATCH 4/4] use deepSupressLongStrings for logging request body (like headers and params) --- src/middleware/error-logger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/middleware/error-logger.js b/src/middleware/error-logger.js index dd583c1f..03f7f72c 100644 --- a/src/middleware/error-logger.js +++ b/src/middleware/error-logger.js @@ -35,7 +35,7 @@ function getLogLevel(status) { function logRequestDetails(logLevel, req) { logger[logLevel]('Request headers:', deepSupressLongStrings(req.headers)); logger[logLevel]('Request parameters:', deepSupressLongStrings(req.params)); - logger[logLevel]('Request body:', req.body); + logger[logLevel]('Request body:', deepSupressLongStrings(req.body)); } function deepSupressLongStrings(obj) {