From ab1cf3c9fee30dce5e7edbd43553b2dd995036c3 Mon Sep 17 00:00:00 2001 From: Anuar Ustayev Date: Mon, 23 Nov 2020 10:51:33 +0600 Subject: [PATCH 1/2] [bug fix][xs]: don't fail if resource.views is undefined. --- routes/dms.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/routes/dms.js b/routes/dms.js index 60371d7e..f0e09859 100644 --- a/routes/dms.js +++ b/routes/dms.js @@ -194,11 +194,13 @@ module.exports = function () { // Prep text views - load first 10Kb of a file to 'content' attribut which // we can render as is in the template. datapackage.displayResources = await Promise.all(datapackage.displayResources.map(async item => { - await Promise.all(item.resource.views.map(async (view, index) => { - if (view && view.specType === 'text' && item.resource.path) { - item.resource.views[index].content = await fetchTextContent(item.resource.path) - } - })) + if (item.resource.views) { + await Promise.all(item.resource.views.map(async (view, index) => { + if (view && view.specType === 'text' && item.resource.path) { + item.resource.views[index].content = await fetchTextContent(item.resource.path) + } + })) + } return item })) From 806c5954463288c7950120abf5452e700ccd80a8 Mon Sep 17 00:00:00 2001 From: Anuar Ustayev Date: Mon, 23 Nov 2020 11:07:02 +0600 Subject: [PATCH 2/2] [logs][s]: make sure to include stack trace if exists. --- utils/logger.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/logger.js b/utils/logger.js index 9da2c94a..6f421509 100644 --- a/utils/logger.js +++ b/utils/logger.js @@ -2,13 +2,14 @@ const winston = require('winston') const config = require('../config/index') const customFormat = winston.format.printf((info) => { - const { level, message, ...meta } = info - return `${meta.timestamp} [${level}] ${message}` + const { level, message, stack, ...meta } = info + return `${meta.timestamp} [${level}] ${message}${stack ? '\n' + stack : ''}` }) const logger = winston.createLogger({ level: config.get('LOG_LEVEL') || 'info', format: winston.format.combine( + winston.format.errors({ stack: true }), winston.format.json(), winston.format.timestamp(), winston.format.colorize(),