-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Supabase: Select Row sometimes returns errors #17057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
WalkthroughThis update primarily increments version numbers across multiple Supabase action and source components. Additionally, a new retry mechanism with exponential backoff was introduced in the Supabase app module, and the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant SupabaseApp as Supabase App
participant SupabaseAPI as Supabase API
Caller->>SupabaseApp: selectRow(args)
SupabaseApp->>SupabaseApp: retryWithExponentialBackoff(func)
SupabaseApp->>SupabaseAPI: execute query
SupabaseAPI-->>SupabaseApp: response or error
alt success
SupabaseApp-->>Caller: return response
else failure and attempts left
SupabaseApp->>SupabaseApp: wait exponential delay
SupabaseApp->>SupabaseAPI: retry query
else failure and no attempts left
SupabaseApp-->>Caller: throw error
end
Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNo out-of-scope changes detected. All changes align with version bumps or the retry logic implementation to address the linked issue. Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
components/supabase/supabase.app.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (4)
components/supabase/actions/batch-insert-rows/batch-insert-rows.mjs (1)
9-9
: Version updated – verify changelog entryOnly the
version
was incremented. Ensure the corresponding changelog (if maintained) records this bump so downstream users understand that no behavioural change was shipped.components/supabase/actions/select-row/select-row.mjs (2)
84-85
: Refine summary message for accurate pluralisation & robustness
row(s)
is serviceable, but a small tweak yields cleaner output and avoids ambiguity while still guarding againstundefined
:-$.export("$summary", `Successfully retrieved ${response.data?.length || 0} row(s) from table ${table}`); +const count = response.data?.length ?? 0; +$.export( + "$summary", + `Successfully retrieved ${count} ${count === 1 ? "row" : "rows"} from table ${table}`, +);
75-83
: Consider propagating the new retry logic to other data-access methods
selectRow
now benefits from the internal exponential-backoff wrapper added insupabase.app.mjs
.
It may be worth providing analogous resilience forinsertRow
,upsertRow
, etc., to offer a uniform developer experience and minimise transient network issues across all actions.components/supabase/supabase.app.mjs (1)
69-70
: Initial delay is 1 s, not the advertisedbaseDelayS
(2 s)Because
Math.pow(baseDelayS, attempt)
starts withattempt = 0
, the first delay becomes1 s
.
If you keep the existing maths, use(attempt + 1)
to honour the stated base.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (11)
components/supabase/actions/batch-insert-rows/batch-insert-rows.mjs
(1 hunks)components/supabase/actions/delete-row/delete-row.mjs
(1 hunks)components/supabase/actions/insert-row/insert-row.mjs
(1 hunks)components/supabase/actions/remote-procedure-call/remote-procedure-call.mjs
(1 hunks)components/supabase/actions/select-row/select-row.mjs
(2 hunks)components/supabase/actions/update-row/update-row.mjs
(1 hunks)components/supabase/actions/upsert-row/upsert-row.mjs
(1 hunks)components/supabase/package.json
(1 hunks)components/supabase/sources/new-row-added/new-row-added.mjs
(1 hunks)components/supabase/sources/new-webhook-event/new-webhook-event.mjs
(1 hunks)components/supabase/supabase.app.mjs
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Lint Code Base
- GitHub Check: Verify TypeScript components
- GitHub Check: Publish TypeScript components
🔇 Additional comments (9)
components/supabase/package.json (1)
3-3
: Approve version bump to 0.3.1
Consistent metadata update aligning with other Supabase component modules.components/supabase/actions/remote-procedure-call/remote-procedure-call.mjs (1)
7-7
: Approve version bump to 0.1.3
No changes to logic; version increment aligns with coordinated updates.components/supabase/actions/update-row/update-row.mjs (1)
7-7
: Approve version bump to 0.1.3
No functional changes; version increment is in sync with other actions.components/supabase/actions/delete-row/delete-row.mjs (1)
7-7
: Approve version bump to 0.1.3
Version update only—logic unchanged and consistent across modules.components/supabase/sources/new-row-added/new-row-added.mjs (1)
12-12
: Approve version bump to 0.0.5
Matches the coordinated version increment across Supabase sources and actions.components/supabase/actions/insert-row/insert-row.mjs (1)
7-7
: Patch-level version bump looks goodNo functional changes are introduced in this file and the version bump keeps semantic-versioning discipline.
Nothing else to flag here.components/supabase/sources/new-webhook-event/new-webhook-event.mjs (1)
8-8
: Source version bump acknowledgedNo additional feedback – implementation remains unchanged.
components/supabase/actions/upsert-row/upsert-row.mjs (1)
7-7
: Minor version increment OKLGTM.
components/supabase/actions/select-row/select-row.mjs (1)
8-8
: Version increment consistent with other actionsNothing further.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
components/supabase/supabase.app.mjs (1)
55-78
: 🛠️ Refactor suggestionExponential-backoff math & recursion could be streamlined
delayMs = Math.pow(baseDelayS, attempt) * 1000
yields 1 s for the first retry regardless ofbaseDelayS
(becauseattempt
starts at 0).
Most callers expect the first retry to waitbaseDelayS
seconds (e.g. 2 s), then 4 s, 8 s…The self-recursion is harmless at 3 attempts, yet a simple loop is clearer and avoids stack growth if
maxAttempts
is increased later.Proposed tweak:
- retryWithExponentialBackoff(func, maxAttempts = 3, baseDelayS = 2) { - let attempt = 0; + async retryWithExponentialBackoff(func, maxAttempts = 3, baseDelayS = 2) { + for (let attempt = 0; attempt < maxAttempts; attempt++) { + try { + const resp = await func(); + this.verifyForErrors(resp); + return resp; + } catch (error) { + if (attempt === maxAttempts - 1) throw error; + + const delayMs = Math.pow(baseDelayS, attempt + 1) * 1000; // 2s, 4s, 8s … + await new Promise((r) => setTimeout(r, delayMs)); + } + } + },Keeps the public contract (“up to
maxAttempts
tries”) while matching the expected delay curve.
🧹 Nitpick comments (1)
components/supabase/supabase.app.mjs (1)
90-97
: Drop the unnecessaryctx
aliasArrow functions already capture
this
; introducingconst ctx = this
is redundant and flagged by Biome (noUselessThisAlias
). Inlinethis
for brevity:- const ctx = this; - const resp = await this.retryWithExponentialBackoff(async () => { - let query = ctx.baseFilter(client, table, orderBy, ascending, max); - if (filter) { - query = ctx[filter](query, column, value); - } + const resp = await this.retryWithExponentialBackoff(async () => { + let query = this.baseFilter(client, table, orderBy, ascending, max); + if (filter) { + query = this[filter](query, column, value); + } return await query; });🧰 Tools
🪛 Biome (1.9.4)
[error] 90-90: This aliasing of this is unnecessary.
Arrow functions inherits
this
from their enclosing scope.
Safe fix: Use this instead of an alias.(lint/complexity/noUselessThisAlias)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
components/supabase/supabase.app.mjs
(2 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
components/supabase/supabase.app.mjs
[error] 90-90: This aliasing of this is unnecessary.
Arrow functions inherits this
from their enclosing scope.
Safe fix: Use this instead of an alias.
(lint/complexity/noUselessThisAlias)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Publish TypeScript components
- GitHub Check: Verify TypeScript components
- GitHub Check: pnpm publish
- GitHub Check: Lint Code Base
🔇 Additional comments (1)
components/supabase/supabase.app.mjs (1)
92-97
: 👍 Query rebuilt per attempt – stale-fetch issue resolvedMoving the query construction inside the retry callback ensures each attempt creates a fresh Postgrest builder. This eliminates the stale / closed fetches problem noted earlier.
/approve |
Resolves #17043
I was able to reproduce the error, but I discovered that it was because my Project had been paused due to inactivity. Once reactivated, the error went away.
However, I found several online comments about similar sporadic errors, and that the "fetch failed" error can stem from various issues, including network problems. So I added a
retryWithExponentialBackoff
method to help reduce errors.Summary by CodeRabbit
New Features
Bug Fixes
Chores