MCPcopy Index your code
hub / github.com/github/copilot-sdk / processEvents

Method processEvents

go/session.go:1368–1388  ·  view source on GitHub ↗

processEvents is the single consumer goroutine for the event channel. It invokes user handlers serially, in arrival order. Panics in individual handlers are recovered so that one misbehaving handler does not prevent others from receiving the event.

()

Source from the content-addressed store, hash-verified

1366// handlers are recovered so that one misbehaving handler does not prevent
1367// others from receiving the event.
1368func (s *Session) processEvents() {
1369 for event := range s.eventCh {
1370 s.handlerMutex.RLock()
1371 handlers := make([]SessionEventHandler, 0, len(s.handlers))
1372 for _, h := range s.handlers {
1373 handlers = append(handlers, h.fn)
1374 }
1375 s.handlerMutex.RUnlock()
1376
1377 for _, handler := range handlers {
1378 func() {
1379 defer func() {
1380 if r := recover(); r != nil {
1381 fmt.Printf("Error in session event handler: %v\n", r)
1382 }
1383 }()
1384 handler(event)
1385 }()
1386 }
1387 }
1388}
1389
1390// handleBroadcastEvent handles broadcast request events by executing local handlers
1391// and responding via RPC. This implements the protocol v3 broadcast model where tool

Callers 2

newTestSessionFunction · 0.95
newSessionFunction · 0.95

Calls 1

handlerFunction · 0.85

Tested by 1

newTestSessionFunction · 0.76