air icon indicating copy to clipboard operation
air copied to clipboard

panic when shutting down with SIGINT signal if proxy is enabled

Open davidovich opened this issue 2 months ago • 7 comments

To reproduce:

  • Start air with proxy enabled in config.
  • Type CTRL-C

Result:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x8 pc=0x100e5b604]

goroutine 5074 [running]:
github.com/cosmtrek/air/runner.(*ProxyStream).RemoveSubscriber(0x14000236588, 0x9b)
        /Users/[user]/go/pkg/mod/github.com/cosmtrek/[email protected]/runner/proxy_stream.go:42 +0xc4
github.com/cosmtrek/air/runner.(*Proxy).reloadHandler.func1()
        /Users/[user]/go/pkg/mod/github.com/cosmtrek/[email protected]/runner/proxy.go:159 +0x84
created by github.com/cosmtrek/air/runner.(*Proxy).reloadHandler in goroutine 4997
        /Users/[user]/go/pkg/mod/github.com/cosmtrek/[email protected]/runner/proxy.go:157 +0x2b8

A theory is that proxy.Stop() is called before the <- ctx.Done() channel yields, allowing making a call on an empty value of the map.

davidovich avatar May 12 '24 21:05 davidovich