Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled promise exceptions #16

Open
toonvd opened this issue Sep 21, 2021 · 1 comment
Open

Unhandled promise exceptions #16

toonvd opened this issue Sep 21, 2021 · 1 comment

Comments

@toonvd
Copy link

toonvd commented Sep 21, 2021

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?

@SaltFish001
Copy link

SaltFish001 commented Oct 31, 2022

You should use server.listen(8085) instead gateway.start(8085)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants