Skip to content

[Spa] Spa proxy enhancements #44638

Closed
@javiercn

Description

@javiercn

This issue tracks three small 'enhancements' to the SPA proxy experience since we would hopefully tackle them together.

1

As part of the changes to 6.0 we delay starting the SPA proxy until the first request arrives as opposed to previous versions where the proxy would start right when the pipeline was built.

In general, it should not matter as the first gesture the user does is going to be opening a browser to navigate to the app. However, it can shave some seconds. This suggestion superseeds #39314

We would add something like

        if (!await _spaProxyLaunchManager.IsSpaProxyRunning(context.RequestAborted))
        {
            _spaProxyLaunchManager.StartInBackground(...);

here (We would need to deal with the async nature by capturing the task and surfacing it later or something like that as well as managing our own cancellation internally).

2

Offer the option to keep the spa proxy running.

When we are in charge of launching the proxy, we also take care of stopping it when the .NET process stops. However, this can lead to a suboptimal experience, for example when using dotnet watch as it sometimes has to restart the process and that results in the proxy stopping and starting (which is cumbersome because it is time consuming).

We should add a KeepRunning option here and avoid launching the watch script here to stop the server.

3

Add a proxy timeout in the proxy config settings to ensure that the proxy responds timely when the request is cancelled on .NET

The fix is to add proxyTimeout: 3000 in https://github.com/dotnet/spa-templates/blob/main/src/content/Angular-CSharp/ClientApp/proxy.conf.js#L6 and https://github.com/dotnet/spa-templates/blob/main/src/content/React-CSharp/ClientApp/src/setupProxy.js#L24 and partially addresses #38917 (we still need to investigate the root cause, but we suspect it is something in node)

Metadata

Metadata

Assignees

Labels

Priority:2Work that is important, but not critical for the releasearea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-spagood first issueGood for newcomers.help wantedUp for grabs. We would accept a PR to help resolve this issue

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions