MCPcopy Create free account
hub / github.com/TanStack/ai / safeEmit

Function safeEmit

packages/ai-event-client/src/devtools-middleware.ts:176–185  ·  view source on GitHub ↗
(...args)

Source from the content-addressed store, hash-verified

174// Wrap an emit so a misbehaving subscriber cannot bubble into the host chat
175// engine. Instrumentation must never break the host app.
176const safeEmit: typeof aiEventClient.emit = (...args) => {
177 try {
178 aiEventClient.emit(...args)
179 } catch (error) {
180 console.error(
181 `[ai-devtools] subscriber threw while handling "${String(args[0])}" event`,
182 error,
183 )
184 }
185}
186
187function buildEventContext(ctx: DevtoolsMiddlewareContext) {
188 return {

Callers 5

onStartFunction · 0.85
onIterationFunction · 0.85
onChunkFunction · 0.85
onToolPhaseCompleteFunction · 0.85
onFinishFunction · 0.85

Calls 2

errorMethod · 0.65
emitMethod · 0.45

Tested by

no test coverage detected