Prevent toSync from clobbering stack traces (#4980)

* Prevent toSync from clobbering stack traces

* Capture error on the outside of the toSync catch

* fmt

* Actually fix it 🤦
This commit is contained in:
49fl
2025-01-08 22:40:42 -05:00
committed by GitHub
parent 73a7e2bfd6
commit 4a654523d2

View File

@ -153,7 +153,10 @@ 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)
void fn(...args).catch((...args) => {
console.error(...args)
return onReject(...args)
})
}
}