MCPcopy Index your code
hub / github.com/codeaashu/claude-code / callSafe

Function callSafe

src/services/analytics/growthbook.ts:110–123  ·  view source on GitHub ↗

Call a listener with sync-throw and async-rejection both routed to logError.

(listener: GrowthBookRefreshListener)

Source from the content-addressed store, hash-verified

108
109/** Call a listener with sync-throw and async-rejection both routed to logError. */
110function callSafe(listener: GrowthBookRefreshListener): void {
111 try {
112 // Promise.resolve() normalizes sync returns and Promises so both
113 // sync throws (caught by outer try) and async rejections (caught
114 // by .catch) hit logError. Without the .catch, an async listener
115 // that rejects becomes an unhandled rejection — the try/catch
116 // only sees the Promise, not its eventual rejection.
117 void Promise.resolve(listener()).catch(e => {
118 logError(e)
119 })
120 } catch (e) {
121 logError(e)
122 }
123}
124
125/**
126 * Register a callback to fire when GrowthBook feature values refresh.

Callers 1

onGrowthBookRefreshFunction · 0.85

Calls 3

listenerFunction · 0.50
logErrorFunction · 0.50
resolveMethod · 0.45

Tested by

no test coverage detected