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

Store the request object in proxy errors #1172

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Store the request object in proxy errors #1172

wants to merge 1 commit into from

Conversation

rowanmanning
Copy link

This would allow someone to differentiate between client errors and
target server errors in their proxy error handling, by inspecting the
error request property.

I'm not sure if this is how you'd prefer to do this, open to alternatives.
The problem I'm trying to solve is in a proxy service I maintain – I'd
like to differentiate between client and server errors in our logging.

This is a potential solution for #1017. E.g:

proxy.on('error', (error, request, response, url) => {
    // Will log either "target" or "forward"
    console.log(`Error came from ${error.request.proxyRequestType}`);
});

This would allow someone to differentiate between client errors and
target server errors in their proxy error handling, by inspecting the
error request property.

This is a potential solution for #1017.
@rowanmanning
Copy link
Author

Tests are failing in Node.js 0.10.x/0.12.x, but it's unrelated to my changes. See #1167.

@jcrugzz
Copy link
Contributor

jcrugzz commented Apr 20, 2018

@rowanmanning I hesitate to add such a heavy object with circular references to the error (because this could cause issues if someone tries to log the error object potentially) but I'm not opposed to attaching metadata so that we can detect the request type and any other relevant information. Is there anything besides type you would want to add?

@rowanmanning
Copy link
Author

Hi @jcrugzz, your hesitance makes perfect sense. I'd be happy to have type metadata, and can't think of anything else off the top of my head. If you don't have time to do the work yourself then I'd also be happy to have a go myself, just might need pointing in the right direction :)

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

Successfully merging this pull request may close these issues.

None yet

2 participants