Skip to content

Store the request object in proxy errors#1172

Open
rowanmanning wants to merge 1 commit intohttp-party:masterfrom
rowanmanning:proxy-error-request
Open

Store the request object in proxy errors#1172
rowanmanning wants to merge 1 commit intohttp-party:masterfrom
rowanmanning:proxy-error-request

Conversation

@rowanmanning
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

2 participants