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

expose the internal 'econreset' error event in proxy options #831

Open
NiccsJ opened this issue Sep 27, 2022 · 0 comments
Open

expose the internal 'econreset' error event in proxy options #831

NiccsJ opened this issue Sep 27, 2022 · 0 comments

Comments

@NiccsJ
Copy link

NiccsJ commented Sep 27, 2022

Describe the feature you'd love to see

In reference to #763 & #759

As of now, only a default log is being printed in these events, there's no way for the user to implement custom logic if these events occur.
Would be great if either this event can be mapped to the 'onError' event handler, or if separate user-defined event handlers can be accepted just like the rest of the events.

current implementation

    proxy.on('econnreset', (error, req, res, target) => {
        logger.error(`[HPM] ECONNRESET: %O`, error);
        console.log('HERE');
    });
    // https://github.com/webpack/webpack-dev-server/issues/1642#issuecomment-1104325120
    proxy.on('proxyReqWs', (proxyReq, req, socket, options, head) => {
        socket.on('error', (error) => {
            logger.error(`[HPM] WebSocket error: %O`, error);
        });
    });
    logger.debug('[HPM] Subscribed to http-proxy events:', Object.keys(handlers));
}

My workaround code

    proxy.on('econnreset', handlers['error']);
    // https://github.com/webpack/webpack-dev-server/issues/1642#issuecomment-1104325120
    proxy.on('proxyReqWs', (proxyReq, req, socket, options, head) => {
        socket.on('error', (error) => {
            logger.error(`[HPM] WebSocket error: %O`, error);
        });
    });
    logger.debug('[HPM] Subscribed to http-proxy events:', Object.keys(handlers));
}

Additional context (optional)

No response

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

1 participant