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

HotReload on linux with firefox #10

Open
ghost opened this issue Aug 12, 2020 · 7 comments
Open

HotReload on linux with firefox #10

ghost opened this issue Aug 12, 2020 · 7 comments

Comments

@ghost
Copy link

ghost commented Aug 12, 2020

Hot reloading doesn't seem to work. What am I missing?

Steps to repro:

  1. dotnet new bolero-app -o MyApp
  2. ASPNETCORE_ENVIRONMENT=Development dotnet run -c Debug -p src/MyApp.Server/
  3. Open browser to http://127.0.0.1:5000
  4. Edit (VsCode) MyApp.Client/wwwroot/main.html "Welcome to Bolero!" to "Welcome to Bolero2!" and press save
  5. Watch text in browser not change.
    Additionally:
  • reloading (F5) and hard reloading (ctrl+shift+r) does not produce any changes
  • shutting down server and restarting it, then rebrowsing to URL also does not produce any changes

System info:
Browser: FF 79.0 64 bit.
.NET Core SDK: 3.1.302
OS: Debian 10

@ghost
Copy link
Author

ghost commented Aug 12, 2020

May be unrelated but I noticed this in the JS console:

mono_wasm_runtime_ready fe00e07a-5519-4dfe-b35a-f867dbaf2e28 dotnet.3.2.0.js:1:133144
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: Value cannot be null. blazor.webassembly.js:formatted:2103
Parameter name: uri blazor.webassembly.js:formatted:2103
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&) blazor.webassembly.js:formatted:2103
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x2a31648 + 0x000ce> in <filename unknown>:0 blazor.webassembly.js:formatted:2103
   --- End of inner exception stack trace --- blazor.webassembly.js:formatted:2103
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x2a31648 + 0x000f6> in <filename unknown>:0 blazor.webassembly.js:formatted:2103
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) <0x2a30ef8 + 0x00014> in <filename unknown>:0 blazor.webassembly.js:formatted:2103
  at Microsoft.AspNetCore.Components.WebAssembly.Hosting.EntrypointInvoker.InvokeEntrypoint (System.String assemblyName, System.String[] args) <0x2a28dd0 + 0x00078> in <filename unknown>:0 blazor.webassembly.js:formatted:2103

@Tarmil
Copy link
Member

Tarmil commented Aug 12, 2020

This looks like the issue that happens with Microsoft.AspNetCore.Components.WebAssembly.Build 3.2.1. It should not be happening with the latest version of the template which forces v3.2.0. Can you check that you have the latest template with this command?

dotnet new --update-check

@ghost
Copy link
Author

ghost commented Aug 12, 2020

I ran this command and got 'No updates found'. I then repro'd using the initial steps and the same issue occurred.

I tried on Windows 10 PC just now and everything works fine. maybe there is some flag to filesystemwatcher thats needed for linux?

MyApp/src/MyApp.Client$ rg Microsoft.AspNetCore.Components.WebAssembly.Build
MyApp.Client.fsproj
15:    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0" />

obj/MyApp.Client.fsproj.nuget.dgspec.json
57:            "Microsoft.AspNetCore.Components.WebAssembly.Build": {

obj/MyApp.Client.fsproj.nuget.g.targets
8:    <Import Project="$(NuGetPackageRoot)microsoft.aspnetcore.components.webassembly.build/3.2.0/build/netstandard1.0/Microsoft.AspNetCore.Components.WebAssembly.Build.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.aspnetcore.components.webassembly.build/3.2.0/build/netstandard1.0/Microsoft.AspNetCore.Components.WebAssembly.Build.targets')" />

obj/MyApp.Client.fsproj.nuget.g.props
17:    <Import Project="$(NuGetPackageRoot)microsoft.aspnetcore.components.webassembly.build/3.2.0/build/netstandard1.0/Microsoft.AspNetCore.Components.WebAssembly.Build.props" Condition="Exists('$(NuGetPackageRoot)microsoft.aspnetcore.components.webassembly.build/3.2.0/build/netstandard1.0/Microsoft.AspNetCore.Components.WebAssembly.Build.props')" />
22:    <PkgMicrosoft_AspNetCore_Components_WebAssembly_Build Condition=" '$(PkgMicrosoft_AspNetCore_Components_WebAssembly_Build)' == '' ">/home/david/.nuget/packages/microsoft.aspnetcore.components.webassembly.build/3.2.0</PkgMicrosoft_AspNetCore_Components_WebAssembly_Build>

obj/project.assets.json
211:      "Microsoft.AspNetCore.Components.WebAssembly.Build/3.2.0": {
217:          "build/netstandard1.0/Microsoft.AspNetCore.Components.WebAssembly.Build.props": {},
218:          "build/netstandard1.0/Microsoft.AspNetCore.Components.WebAssembly.Build.targets": {}
1844:    "Microsoft.AspNetCore.Components.WebAssembly.Build/3.2.0": {
1854:        "build/netstandard1.0/Microsoft.AspNetCore.Components.WebAssembly.Build.props",
1855:        "build/netstandard1.0/Microsoft.AspNetCore.Components.WebAssembly.Build.targets",
1875:        "tools/netcoreapp/Microsoft.AspNetCore.Components.WebAssembly.Build.Tasks.dll",
1876:        "tools/netfx/Microsoft.AspNetCore.Components.WebAssembly.Build.Tasks.dll",
5551:      "Microsoft.AspNetCore.Components.WebAssembly.Build >= 3.2.0",
5609:          "Microsoft.AspNetCore.Components.WebAssembly.Build": {

@ghost
Copy link
Author

ghost commented Aug 12, 2020

I tested with the below, and it seems to work. After seeing this comment https://github.com/dotnet/corefxlab/blob/master/src/System.IO.FileSystem.Watcher.Polling/System/IO/PollingFileSystemWatcher.cs#L16

dotnet add package System.IO.FileSystem.Watcher.Polling --version 0.1.2-e200127-1 --source https://dotnet.myget.org/F/dotnet-corefxlab/api/v3/index.json then

Templating.fs:Watcher:
        let callback (args: PollingFileSystemEventArgs) =
            // filter later
            args.Changes |> Seq.iter (fun e -> delayedOnchange (Path.Combine(e.Directory, e.Name)))

        member this.Start() =
            let fsw = // leaks
                new PollingFileSystemWatcher(dir, "*.html",options=EnumerationOptions(RecurseSubdirectories=true))

            fsw.ChangedDetailed.Add callback
            fsw.Start()

            TemplateCache.client <-
                { new Client.ClientBase() with
                    member __.SetOnChange(_) = ()
                    member __.RequestFile(filename) =
                        onchange (fullPathOf filename)
                }

@Tarmil
Copy link
Member

Tarmil commented Aug 13, 2020

Ah, this is a good catch, thanks for investigating this issue!

@ghost
Copy link
Author

ghost commented Aug 14, 2020

@Tarmil no problem, I wanted to learn webdev anyway :D.

I think the issue will be how this is fixed, its not ideal to rely on myget packages (they can suddenly disappear), and its also tricky for users to compile the fixes themselves (as it causes dev time issues with type provider).

We might be able to ask corefxlab team to publish System.IO.FileSystem.Watcher.Polling to nuget, but I don't know how likely that is (@cartermp would probably know!)

Other option is to implement a polling watcher ourselves, but this area is not trivial.

@cartermp
Copy link

Unfortunately I'm not sure when they would do that. i'd create an issue on their repo, though

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

No branches or pull requests

2 participants