low-http-server
low-http-server copied to clipboard
Unhandled promise exceptions
Hi
When using this lib combined with restana
and fast-proxy
, I get the following warnings:
(node:2393512) UnhandledPromiseRejectionWarning: [object Object]
(node:2393512) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2393512) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I can't seem to pinpoint the cause of it but it only happens when I this lib as the server:
#!/usr/bin/nodejs
'use strict';
const vhostIP = process.env.VHOSTIP;
const server = require('low-http-server')();
const pump = require('pump');
const { proxy } = require('fast-proxy')({
base: `http://${vhostIP}:7080`,
undici: true
});
const gateway = require('restana')({
server: server,
prioRequestsProcessing: false
});
gateway.all('/*', function (req, res) {
proxy(req, res, req.url, {
rewriteRequestHeaders(req, headers) {
delete headers.connection
headers.host = headers['x-forwarded-host'];
return headers
},
async onResponse(req, res, stream) {
pump(stream, res)
}
});
});
gateway.start(8085);
I was also wondering if adding low-http-server
to this setup would have any impact since the proxy / undici would probably become the bottleneck?
You should use server.listen(8085)
instead gateway.start(8085)