TheAngryByrd / MiniScaffold

F# Template for creating and publishing libraries targeting .NET 6.0 `net6.0` or console apps .NET 6.0 `net6.0`.
https://www.jimmybyrd.me/MiniScaffold/
MIT License
267 stars 31 forks source link

WatchDocs watcher fails to resume watching if docsTool throws an exception #183

Closed rmunn closed 1 year ago

rmunn commented 4 years ago

Describe the bug When running the WatchDocs target, if docsTool exits with a non-zero exit code due to an exception being thrown, the watcher fails to resume watching the file. After undoing the edit that caused the exception to be thrown, I expected my browser window to continue live reloading, but it didn't. I had to Ctrl+C the WatchDocs target and run it again in order to get live reload back in my browser window.

To Reproduce Steps to reproduce the behavior:

  1. Create a new project from the template
  2. ./build.sh WatchDocs
  3. Edit docsSrc/index.md and add the following snippet:
    let x = 5 + 7
  4. Save and watch the code snippet update live in the browser
  5. Now edit the code snippet to be:
    let x = 5 + 7
    printfn "%A" x
  6. docsTool throws an exception:

    Unhandled exception. System.Exception: error while formatting file /home/rmunn/path/to/project/docsSrc/index.md. Errors are: seq [SourceError ((0, 0),(0, 0),Error, "The type 'TextWriter' is required here and is unavailable. You must add a reference to assembly 'System.Runtime.Extensions, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.")] at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1637.Invoke(String message) in E:\A_work\130\s\src\fsharp\FSharp.Core\printf.fs:line 1637 at Program.GenerateDocs.format@266-2.Invoke(IEnumerable`1 arg20) in /home/rmunn/path/to/project/docsTool/Program.fs:line 266 ... snip rest of exception for length ...

  7. Edit the code snippet again to remove the printfn "%A" x line, and save the file
  8. Browser doesn't refresh. Hitting Ctrl+R in the browser reveals that there is no longer a server serving HTTP on localhost:5000.
  9. Editing a file in src/ProjectName/*.fs will cause the dotnet build watch to rebuild the project, but nothing seems to cause the docsTool watch to come back.

Expected behavior I would expect the HTTP server serving up the local documentation files to stay up even if parsing fails. I would also expect the watch to keep watching the docsSrc/*.md files, so that once I delete the line that caused the exception and save the file, the watch would pick up on the save, re-parse the file (successfully), and refresh the browser tab again.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

TheAngryByrd commented 1 year ago

Since we're replacing docsTool with fsdoc (#270), going to close this.