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

Revisit hot reload browser refresh script injection #45213

Open
2 tasks
MackinnonBuck opened this issue Nov 21, 2022 · 5 comments
Open
2 tasks

Revisit hot reload browser refresh script injection #45213

MackinnonBuck opened this issue Nov 21, 2022 · 5 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-hot-reload This issue is related to the Hot Reload feaature Pillar: Dev Experience Priority:1 Work that is critical for the release, but we could probably ship without triaged

Comments

@MackinnonBuck
Copy link
Member

MackinnonBuck commented Nov 21, 2022

Our hot reload mechanism relies on the aspnetcore-browser-refresh.js script being injected into the webpage so the browser can automatically refresh with hot reload changes.

We currently do this with a special middleware that searches for the last closing </body> tag in HTML responses and injects a <script src="/_framework/aspnetcore-browser-refresh.js"></script> element just before it. However, this mechanism is very fragile because it fails when the response can't be easily parsed (e.g., response compression is enabled, the closing </body> tag is split between response stream writes, etc.).

We should consider an approach where we somehow reference the browser refresh script directly rather than using this script injection middleware.

Additional considerations

Make sure we also address the following issues:

@MackinnonBuck MackinnonBuck added the feature-hot-reload This issue is related to the Hot Reload feaature label Nov 21, 2022
@mkArtakMSFT mkArtakMSFT added area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one labels Nov 22, 2022
@mkArtakMSFT mkArtakMSFT added this to the .NET 8 Planning milestone Nov 22, 2022
@ghost
Copy link

ghost commented Nov 22, 2022

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@ghost
Copy link

ghost commented Jun 29, 2023

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@ghost
Copy link

ghost commented Dec 21, 2023

Thanks for contacting us.

We're moving this issue to the .NET 9 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@MackinnonBuck MackinnonBuck added the Priority:1 Work that is critical for the release, but we could probably ship without label Jan 18, 2024
@javiercn
Copy link
Member

One thought I'm leaving here so we don't forget.

We should make these scripts ES6 modules and rely on import.meta.url as that will decouple us from the base and allow us to always refer to endpoints, etc. in a way that is relative to the location of the hot-reload script.

@daiplusplus
Copy link

daiplusplus commented May 24, 2024

After experiencing numerous difficulties with disabling VS's (and ASP.NET Core's) script injection feature, I'd like to request that all injected HTML should include a HTML comment with instructions on how to disable HTML injection.

So instead of this (which is what we have right now):

<script src="/_framework/aspnetcore-browser-refresh.js"></script></body>
</html>

...it should be something like this:

<!-- BEGIN Visual Studio 2022 Hot Reload script (for CSS Hot Reload / Blazor Hot Reload / BrowserLink / Etc).
This can be disabled under Tools > Options > Projects and Solutions > ASP.NET Core, and by adding "hotReloadEnabled": false to your launchSettings.json profile. -->
<script src="/_framework/aspnetcore-browser-refresh.js"></script>
<!-- END  Visual Studio 2022 Hot Reload.
</body>
</html>

...because right now the Hot Reload script will be injected if any of 4 entirely different VS or Project options are configured a certain way, and there's no obvious way to disable it. I would also like to have a single "Disable all code-injections" option so I won't have code unexpectedly injected for something-else-other-than-Hot-Reload in future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-hot-reload This issue is related to the Hot Reload feaature Pillar: Dev Experience Priority:1 Work that is critical for the release, but we could probably ship without triaged
Projects
None yet
Development

No branches or pull requests

4 participants