livebud/bud

Cryptic panic when livereload server fails to start

オープン

#83 opened on 2022/05/23

 (1 件のコメント) (0 件のリアクション) (0 人の担当者)JavaScript (211 件のフォーク)batch import
help wantedneeds retest

Repository metrics

Stars
 (5,391 個のスター)
PR merge metrics
 (30d に merged PR はありません)

説明

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/sync@v0.0.0-20220513210516-0976fa681c29/errgroup/errgroup.go:74 +0x64
    created by golang.org/x/sync/errgroup.(*Group).Go
    				/Users/m/dev/pkg/mod/golang.org/x/sync@v0.0.0-20220513210516-0976fa681c29/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

コントリビューターガイド