Skip to content

fix(postgrest): then typing#2349

Merged
mandarini merged 4 commits into
supabase:masterfrom
7ttp:fix/then-error
Jun 8, 2026
Merged

fix(postgrest): then typing#2349
mandarini merged 4 commits into
supabase:masterfrom
7ttp:fix/then-error

Conversation

@7ttp

@7ttp 7ttp commented May 10, 2026

Copy link
Copy Markdown
Contributor

TL;DR

fixes throwOnError typing in .then() chains so success responses no longer stay nullable after .throwOnError()
also added a small test for it

ref:

@7ttp 7ttp requested review from a team as code owners May 10, 2026 19:03
@pkg-pr-new

pkg-pr-new Bot commented May 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

@supabase/auth-js

npm i https://pkg.pr.new/@supabase/auth-js@2349

@supabase/functions-js

npm i https://pkg.pr.new/@supabase/functions-js@2349

@supabase/postgrest-js

npm i https://pkg.pr.new/@supabase/postgrest-js@2349

@supabase/realtime-js

npm i https://pkg.pr.new/@supabase/realtime-js@2349

@supabase/storage-js

npm i https://pkg.pr.new/@supabase/storage-js@2349

@supabase/supabase-js

npm i https://pkg.pr.new/@supabase/supabase-js@2349

commit: 3c0121c

@7ttp 7ttp force-pushed the fix/then-error branch from 8070a7a to a2210bd Compare May 10, 2026 20:37
@7ttp 7ttp force-pushed the fix/then-error branch from a2210bd to 1845b44 Compare May 10, 2026 21:00
@7ttp 7ttp marked this pull request as draft May 10, 2026 21:44
@mandarini

Copy link
Copy Markdown
Contributor

@7ttp are you still working on this?

@7ttp

7ttp commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

mb almost forgot abt this, will have a look at it today...

@7ttp 7ttp marked this pull request as ready for review June 4, 2026 18:02
Comment thread packages/core/postgrest-js/src/PostgrestFilterBuilder.ts
@7ttp

7ttp commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

cc @mandarini

@mandarini mandarini self-assigned this Jun 5, 2026
@mandarini

Copy link
Copy Markdown
Contributor

Helloooo! A few small things before I merge:

  1. In test/index.test-d.ts, the existing expectType<typeof y extends typeof x ? true : false>(true) got removed. The new w extends y check is great but tests a different thing. Could we replace the dropped assertion with a positive one that documents the new relationship?

  2. The new test covers .single().throwOnError().then(...). Could we add a couple more .then() shapes? The existing tests cover these for await, but .then() is a different code path:

    • .maybeSingle().throwOnError().then(...) (trickiest, should stay nullable)
    • .throwOnError().single().then(...) (throwOnError before single)
    • .throwOnError().eq('x', 1).then(...) (no single at all)

Wdyt?

@7ttp

7ttp commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

Helloooo! A few small things before I merge:

1. In `test/index.test-d.ts`, the existing `expectType<typeof y extends typeof x ? true : false>(true)` got removed. The new `w extends y` check is great but tests a different thing. Could we replace the dropped assertion with a positive one that documents the new relationship?

2. The new test covers `.single().throwOnError().then(...)`. Could we add a couple more `.then()` shapes? The existing tests cover these for `await`, but `.then()` is a different code path:
   
   * `.maybeSingle().throwOnError().then(...)` (trickiest, should stay nullable)
   * `.throwOnError().single().then(...)` (throwOnError before single)
   * `.throwOnError().eq('x', 1).then(...)` (no single at all)

Wdyt?

ah! makes sense
js swapped the dropped assertion for a positive x -> throwOnError(x) check and
added the extra .then() cases you called out...

@mandarini mandarini merged commit 21e9d4b into supabase:master Jun 8, 2026
21 checks passed
@7ttp 7ttp deleted the fix/then-error branch June 8, 2026 13:45
mandarini pushed a commit to supabase/supabase that referenced this pull request Jun 16, 2026
This PR updates @supabase/*-js libraries to version 2.108.2.

**Source**: supabase-js-stable-release

**Changes**:
- Updated @supabase/supabase-js to 2.108.2
- Updated @supabase/auth-js to 2.108.2
- Updated @supabase/realtime-js to 2.108.2
- Updated @supabase/postgest-js to 2.108.2
- Refreshed pnpm-lock.yaml

---

## Release Notes

## v2.108.2

## 2.108.2 (2026-06-15)

### 🩹 Fixes

- **auth:** preserve valid session on refresh failure and cooldown
repeat failures
([#2436](supabase/supabase-js#2436))
- **realtime:** clarify httpSend() 404 error and server migration note
([#2444](supabase/supabase-js#2444))
- **release:** pin Deno and bound JSR publish to survive stranded-task
hangs ([#2439](supabase/supabase-js#2439))
- **release:** restore JSR publish flags and enable for beta
([#2440](supabase/supabase-js#2440))

### ❤️ Thank You

- Katerina Skroumpelou @mandarini
## v2.108.1

## 2.108.1 (2026-06-09)

### 🩹 Fixes

- **ci:** forward DOGFOOD_APP_CLIENT_ID to dogfood workflow
([#2434](supabase/supabase-js#2434))
- **postgrest:** then typing
([#2349](supabase/supabase-js#2349))

### ❤️ Thank You

- Katerina Skroumpelou @mandarini
- Vaibhav @7ttp

This PR was created automatically.

Co-authored-by: supabase-workflow-trigger[bot] <266661614+supabase-workflow-trigger[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.throwOnError() only adjusts types correctly if await is used and is still incorrect if you use then

2 participants