fix(event-stream): isolate subscriber failures (#1235)
* fix(event-stream): isolate subscriber failures * fix(event-stream): handle async subscriber failures --------- Co-authored-by: Isaac Sanchez <isanchez-hawkins@arize.com>
This commit is contained in:
committed by
GitHub
co-authored by
Isaac Sanchez
parent
df12c3a2b5
commit
7721c2fe10
@@ -22,9 +22,22 @@ export function createGlobalMessageStreamHub({
|
||||
let everConnected = false;
|
||||
let buildUrlFailed = false;
|
||||
|
||||
const notifySubscriber = (kind, subscriber, payload) => {
|
||||
try {
|
||||
const result = subscriber(payload);
|
||||
if (result && typeof result.catch === 'function') {
|
||||
result.catch((error) => {
|
||||
console.warn(`Global message stream ${kind} subscriber failed:`, error);
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(`Global message stream ${kind} subscriber failed:`, error);
|
||||
}
|
||||
};
|
||||
|
||||
const notifyStatus = (status) => {
|
||||
for (const subscriber of Array.from(statusSubscribers)) {
|
||||
subscriber(status);
|
||||
notifySubscriber('status', subscriber, status);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -81,7 +94,7 @@ export function createGlobalMessageStreamHub({
|
||||
}
|
||||
|
||||
for (const subscriber of Array.from(eventSubscribers)) {
|
||||
subscriber(normalized);
|
||||
notifySubscriber('event', subscriber, normalized);
|
||||
}
|
||||
},
|
||||
onError(error) {
|
||||
|
||||
Reference in New Issue
Block a user