func Wait will panic, because callback is nil.
Can func Wait support nil callback? Maybe do nothing when callback is nil is better
st := stream.New().WithMaxGoroutines(20) st.Go(func() stream.Callback { return nil } st.Wait()
There is an example. Recover() in st.Go works, but st.Wait() still panic.
package main import ( "fmt" "github.com/sourcegraph/conc/stream" "time" ) func main() { for i := 0; i < 5; i++ { st := stream.New().WithMaxGoroutines(20) for i := 0; i < 10; i++ { idx := i st.Go(func() (callback stream.Callback) { //callback = func() {} // if comment will panic defer func() { if err := recover(); err != nil { fmt.Println("haha", err) } }() if idx == 2 || idx == 4 { panic(idx) // this panic will be recovered } return func() { } }) } st.Wait() // panic occurs here } time.Sleep(1 * time.Second) }
Looks like this is already fixed on main — callbacker skips nil callbacks (and there's a "nil callback" test). Safe to close?
Activity
rhyshmwang commentedon Nov 15, 2024
There is an example. Recover() in st.Go works, but st.Wait() still panic.
TastyHeadphones commentedon Sep 27, 2026
Looks like this is already fixed on main — callbacker skips nil callbacks (and there's a "nil callback" test). Safe to close?