diff --git a/examples/suspense/main.templ b/examples/suspense/main.templ index 1c4803e8a..3145d2dd3 100644 --- a/examples/suspense/main.templ +++ b/examples/suspense/main.templ @@ -9,7 +9,9 @@ import ( func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { // Create a channel to send deferred component renders to the template. - data := make(chan SlotContents) + // Buffer for the known 3 slots so a goroutine never blocks on send if + // the client disconnects before the template finishes reading. + data := make(chan SlotContents, 3) // We know there are 3 slots, so start a WaitGroup. var wg sync.WaitGroup diff --git a/examples/suspense/main_templ.go b/examples/suspense/main_templ.go index 650289724..d6723617c 100644 --- a/examples/suspense/main_templ.go +++ b/examples/suspense/main_templ.go @@ -16,7 +16,9 @@ import ( func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { // Create a channel to send deferred component renders to the template. - data := make(chan SlotContents) + // Buffer for the known 3 slots so a goroutine never blocks on send if + // the client disconnects before the template finishes reading. + data := make(chan SlotContents, 3) // We know there are 3 slots, so start a WaitGroup. var wg sync.WaitGroup