diff --git a/http/http-error-handler.js b/http/http-error-handler.js index d8154e9..514cac8 100644 --- a/http/http-error-handler.js +++ b/http/http-error-handler.js @@ -1,11 +1,11 @@ // eslint-disable-next-line complexity const errorHandler = ({verbose = true} = {}) => (error, { log, - id, ip, hostname, originalUrl, url, + id, ip, hostname, originalUrl, url, body, }, reply) => { log.debug({ - id, ip, hostname, originalUrl, url, + id, ip, hostname, originalUrl, url, body, }) const code = error.status || error.statusCode || 500 const toPrint = verbose === true ? error : {message: error.message} diff --git a/package.json b/package.json index 05c9365..8d1dc46 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "moar-js", - "version": "1.1.0", + "version": "1.1.1", "description": "Simple JavaScript files I use across projects", "author": { "name": "Daniele Dellafiore" diff --git a/tests/http/routes.js b/tests/http/routes.js index c58dcbb..36a80d4 100644 --- a/tests/http/routes.js +++ b/tests/http/routes.js @@ -1,5 +1,7 @@ const {defaultHttpJsonClient} = require('../../axios') +const {__} = require('../../fusto/') +// eslint-disable-next-line max-lines-per-function module.exports = app => { app.get('/health', request => { const ip = request.socket.remoteAddress @@ -32,4 +34,33 @@ module.exports = app => { const {get} = defaultHttpJsonClient('http://duckduckgo.com', {timeout: 1}) await get('/') }) - return app} + + app.get('/async-pipe-booom', async (request, reply) => { + await __([1]) + // eslint-disable-next-line require-await + .map(async () => { + // eslint-disable-next-line fp/no-throw + throw new Error('big booom in the async pipeline') + }) + .resolve() + .errors((error, push) => push(error)) + .toPromise() + reply.code(200).send({}) + }) + + app.get('/hijack-async-pipe-booom', async (request, reply) => { + reply.hijack() + await __([1]) + // eslint-disable-next-line require-await + .map(async () => { + // eslint-disable-next-line fp/no-throw + throw new Error('big booom in the async pipeline') + }) + .resolve() + .errors((error, push) => push(error)) + .toPromise(() => reply.code(200).send({})) + return 'This will be ignored.' + }) + + return app +}