Skip to content

Commit

Permalink
Prevent toSync from clobbering stack traces
Browse files Browse the repository at this point in the history
  • Loading branch information
lf94 committed Jan 8, 2025
1 parent eb0850f commit e9cd815
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,12 @@ export function toSync<F extends AsyncFn<F>>(
) => void | PromiseLike<void | null | undefined> | null | undefined
): (...args: Parameters<F>) => void {
return (...args: Parameters<F>) => {
fn(...args).catch(onReject)
try {
void fn(...args)
} catch(e) {
console.trace()
void onReject(e)
}
}
}

Expand Down

0 comments on commit e9cd815

Please sign in to comment.