Skip to content

Commit

Permalink
Capture stack traces in user queue errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gc committed Feb 28, 2024
1 parent dbc8598 commit 6078da7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/lib/util/userQueues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,13 @@ export function getUserUpdateQueue(userID: string) {

export async function userQueueFn<T>(userID: string, fn: () => Promise<T>) {
const queue = getUserUpdateQueue(userID);
return queue.add(() => fn());
return queue.add(async () => {
const error = new Error();
try {
return await fn();
} catch (e) {
error.message = (e as Error).message;
throw error;
}
});
}

0 comments on commit 6078da7

Please sign in to comment.