Skip to content

UseProxyToSpaDevelopmentServer slow when passing 'Connection' header #16797

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

Closed
ChristopherHaws opened this issue Nov 3, 2019 · 2 comments
Closed
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed help wanted Up for grabs. We would accept a PR to help resolve this issue

Comments

@ChristopherHaws
Copy link
Contributor

ChristopherHaws commented Nov 3, 2019

Describe the bug

When using UseProxyToSpaDevelopmentServer I noticed that all requests to the proxy were taking over 1 second to complete. When I access the resource directly (not via the SPA proxy) it takes about 2ms. After some debugging, I found that the cause is the Connection header being passed to the proxied server. When I remove the Connection header, the request now takes about 40ms.

https://github.com/aspnet/AspNetCore/blob/master/src/Middleware/SpaServices.Extensions/src/Proxying/SpaProxy.cs#L133

To Reproduce

Steps to reproduce the behavior:

  1. Create an ASP.NET Core 3.0 app that uses UseProxyToSpaDevelopmentServer
  2. I am using webpack-dev-server as the dev server (not sure if this matters or not)
  3. Notice that every proxied request takes 1+ seconds

Expected behavior

The request should respond with similar times as the dev server. I can understand some overhead since it is copying the request and response, but not 500x slower.

Additional notes

I'm not sure if I should make a separate bug for this, but I also ran into an issue with the cookie header getting copied which causes requests to fail. I had to add a pretty hacky solution to our project that removes the cookie header before calling the proxy middleware. I believe the cause of the error is specifically when there is a SameSite=strict cookie since it happens when i have a CSRF cookie.

Perhaps one mitigation could be to add the ability to disable copying headers or add an allowed/disallowed headers as an option on UseProxyToSpaDevelopmentServer.

@javiercn javiercn added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates help wanted Up for grabs. We would accept a PR to help resolve this issue labels Nov 4, 2019
@javiercn
Copy link
Member

javiercn commented Nov 4, 2019

@ChristopherHaws thanks for contacting us.

Would you like to provide a PR to improve this behavior?

@javiercn javiercn added the bug This issue describes a behavior which is not expected - a bug. label Nov 4, 2019
@javiercn javiercn added this to the Backlog milestone Nov 4, 2019
@mkArtakMSFT mkArtakMSFT added the Done This issue has been fixed label Nov 11, 2019
@mkArtakMSFT mkArtakMSFT modified the milestones: Backlog, 5.0.0-preview1 Nov 11, 2019
@mkArtakMSFT
Copy link
Contributor

Thanks for your contribution, @ChristopherHaws 👍

@ghost ghost locked as resolved and limited conversation to collaborators Dec 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed help wanted Up for grabs. We would accept a PR to help resolve this issue
Projects
None yet
Development

No branches or pull requests

3 participants