bud icon indicating copy to clipboard operation
bud copied to clipboard

Cryptic panic when livereload server fails to start

Open matthewmueller opened this issue 3 years ago • 1 comments

There's a couple issues here that need to be fixed:

  1. 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.

  2. 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 +0xa5
    

    The problem is that process is nil for some reason when calling the following: https://github.com/livebud/bud/blob/63900d258ae92faa4faf14e834021347f202d8a1/runtime/command/run/run.go#L75

  3. 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

  1. 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")
}
  1. Within the bud repository, call go run main.go -C examples/hn run

matthewmueller avatar May 23 '22 05:05 matthewmueller

Not sure if this is still an issue anymore in v0.1.9. Should be tried again.

matthewmueller avatar Jun 27 '22 06:06 matthewmueller