Cryptic panic when livereload server fails to start
There's a couple issues here that need to be fixed:
-
For some reason the hot reload port wasn't released, despite the application port being released. I'm not able to reproduce this behavior at the moment, so let's just keep an eye on it for now.
-
Nil pointer panic on *exe.Close
panic: runtime error: invalid memory address or nil pointer dereference panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0xa0 pc=0x148aa70] goroutine 66 [running]: github.com/livebud/bud/package/exe.(*Cmd).Close(0x0) /Users/m/dev/src/github.com/livebud/bud/package/exe/command.go:24 +0x70 panic({0x151a1a0, 0x19de710}) /usr/local/go/src/runtime/panic.go:838 +0x207 os/exec.(*Cmd).Wait(0x173cec0?) /usr/local/go/src/os/exec/exec.go:499 +0x18 github.com/livebud/bud/package/exe.(*Cmd).Wait(...) /Users/m/dev/src/github.com/livebud/bud/package/exe/command.go:39 github.com/livebud/bud/runtime/command/run.(*Command).startApp(0xc000256f60, {0x173cec0?, 0xc00024d300}, 0xc000243490) /Users/m/dev/src/github.com/livebud/bud/runtime/command/run/run.go:115 +0x3c5 github.com/livebud/bud/runtime/command/run.(*Command).Run.func2() /Users/m/dev/src/github.com/livebud/bud/runtime/command/run/run.go:37 +0x29 golang.org/x/sync/errgroup.(*Group).Go.func1() /Users/m/dev/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:74 +0x64 created by golang.org/x/sync/errgroup.(*Group).Go /Users/m/dev/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:71 +0xa5The problem is that
processis nil for some reason when calling the following: https://github.com/livebud/bud/blob/63900d258ae92faa4faf14e834021347f202d8a1/runtime/command/run/run.go#L75 -
Need a better error for unable to start the live reload server. Perhaps:
fmt.Errorf("Error starting the live reload server on %s: %w", address, err)Eventually, I'd like to find a free port and propagate the change accordingly, but for now, I think we just supply a better error.
Steps to reproduce
- This can be reproduced by altering the following:
https://github.com/livebud/bud/blob/63900d258ae92faa4faf14e834021347f202d8a1/runtime/command/run/run.go#L117-L120
func (c *Command) startHot(ctx context.Context, hotServer *hot.Server) error {
// TODO: host should be dynamic
+ return fmt.Errorf("failed to listen")
- return hotServer.ListenAndServe(ctx, "127.0.0.1:35729")
}
- Within the bud repository, call
go run main.go -C examples/hn run
Not sure if this is still an issue anymore in v0.1.9. Should be tried again.