Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Commit 0b4968d

Browse files
authored
fix: maybeSingle: Avoid uncaught promise rejection (#210)
Not all errors returned by postgrest contain the `details` field (in particular, 401 errors due to invalid/expired JWT tokens). Hence, this PR avoids an uncaught promise rejection by ensuring that `error.details` field exists before checking the error details for the "Results contain 0 rows" message.
1 parent 44d847c commit 0b4968d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lib/PostgrestTransformBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export default class PostgrestTransformBuilder<T> extends PostgrestBuilder<T> {
104104
const _this = new PostgrestTransformBuilder(this)
105105
_this.then = ((onfulfilled: any, onrejected: any) =>
106106
this.then((res: any): any => {
107-
if (res.error?.details.includes('Results contain 0 rows')) {
107+
if (res.error?.details?.includes('Results contain 0 rows')) {
108108
return onfulfilled({
109109
error: null,
110110
data: null,

0 commit comments

Comments
 (0)