-
Notifications
You must be signed in to change notification settings - Fork 54
Description
Describe the feature request
Context
Currently, the Unleash SDK emits error messages without distinguishing their source.
For example:
Unleash: unable to send feature metrics TypeError: Failed to fetch
or
Unleash: unable to fetch feature toggles TypeError: Failed to fetch
However, when the SDK propagates the error event, the received object only contains the native exception (TypeError: Failed to fetch), without any indication of whether the failure happened when sending metrics or when fetching feature toggles.
Problem
In some scenarios, it’s important to distinguish between:
Failure while fetching toggles → critical → requires fallback (e.g., using CDN or local cache) and logging.
Failure while sending metrics → non-critical → can be ignored or logged at a lower priority.
Right now, there’s no reliable way to make this distinction using only the Error object.
Background
No response
Solution suggestions
Proposal
Add extra metadata to the emitted error event. For example:
emitter.emit('error', {
type: 'metrics',
error, // native error object
})
emitter.emit('error', {
type: 'fetch-toggles',
error,
})
Alternatively, the SDK could attach a property to the error object (error.context = 'metrics').
This would allow consumers to safely filter errors:
client.on('error', (err) => {
if (err.type === 'fetch-toggles') {
triggerFallback()
captureMessage('Unleash flags fetch failed', { level: 'warning' })
}
})
Metadata
Metadata
Assignees
Labels
Type
Projects
Status