Skip to content

fix(storage): make StreamDownloadBuilder implement Promise and memoize executor#2367

Merged
mandarini merged 1 commit into
supabase:masterfrom
oniani1:fix/stream-download-builder-promise-interface
May 18, 2026
Merged

fix(storage): make StreamDownloadBuilder implement Promise and memoize executor#2367
mandarini merged 1 commit into
supabase:masterfrom
oniani1:fix/stream-download-builder-promise-interface

Conversation

@oniani1

@oniani1 oniani1 commented May 12, 2026

Copy link
Copy Markdown
Contributor

Closes #2366.

Summary

StreamDownloadBuilder declared PromiseLike instead of Promise, so it lacked catch, finally, and [Symbol.toStringTag]. Its then also ran execute() on every call, which meant each await re-issued the underlying fetch.

This change rewrites the class to mirror the sibling BlobDownloadBuilder: it now implements Promise<DownloadResult<ReadableStream>>, caches the in-flight promise in a private getPromise(), and adds the missing catch, finally, and Symbol.toStringTag members. The constructor signature, exports, and execute() body are unchanged.

Test plan

Added test/downloadBuilders.test.ts covering five behaviors on the stream builder (single executor call across multiple awaits, .catch(), .finally(), Symbol.toStringTag, Promise assignability), plus two regression checks on BlobDownloadBuilder. All seven pass.

…e executor

StreamDownloadBuilder declared PromiseLike instead of Promise, so it lacked
catch, finally, and [Symbol.toStringTag]. Its then also ran execute() on every
call, which meant each await re-issued the underlying fetch.

Rewrites the class to mirror BlobDownloadBuilder: implements
Promise<DownloadResult<ReadableStream>>, caches the in-flight promise in a
private getPromise(), and adds catch, finally, and Symbol.toStringTag. The
constructor signature, exports, and execute() body are unchanged.

Added test/downloadBuilders.test.ts covering five behaviors on the stream
builder (single executor call across multiple awaits, .catch(), .finally(),
Symbol.toStringTag, Promise assignability), plus two regression checks on
BlobDownloadBuilder.
@oniani1 oniani1 requested review from a team as code owners May 12, 2026 20:23

@mandarini mandarini left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this @oniani1

@pkg-pr-new

pkg-pr-new Bot commented May 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

@supabase/auth-js

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

@supabase/functions-js

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

@supabase/postgrest-js

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

@supabase/realtime-js

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

@supabase/storage-js

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

@supabase/supabase-js

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

commit: 2da36fd

@mandarini mandarini merged commit ec39c4f into supabase:master May 18, 2026
22 checks passed
mandarini pushed a commit to supabase/ssr that referenced this pull request May 18, 2026
This PR updates `@supabase/supabase-js` to v2.106.0.

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

---

## Release Notes

## v2.106.0

## 2.106.0 (2026-05-18)

### 🚀 Features

- **supabase:** W3C/OpenTelemetry trace context propagation
([#2163](supabase/supabase-js#2163))

### 🩹 Fixes

- **auth:** return null user and session for email_change
single-confirmation verifyOtp
([#2378](supabase/supabase-js#2378))
- **release:** mark @supabase/tracing private and snapshot it for JSR
([#2370](supabase/supabase-js#2370))
- **storage:** make StreamDownloadBuilder implement Promise and memoize
executor ([#2367](supabase/supabase-js#2367))

### ❤️ Thank You

- Claude Sonnet 4.5
- Guilherme Souza
- Katerina Skroumpelou @mandarini
- oniani1

This PR was created automatically.

Co-authored-by: supabase-workflow-trigger[bot] <266661614+supabase-workflow-trigger[bot]@users.noreply.github.com>
mandarini pushed a commit to supabase/supabase that referenced this pull request May 19, 2026
This PR updates @supabase/*-js libraries to version 2.106.0.

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

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

---

## Release Notes

## v2.106.0

## 2.106.0 (2026-05-18)

### 🚀 Features

- **supabase:** W3C/OpenTelemetry trace context propagation
([#2163](supabase/supabase-js#2163))

### 🩹 Fixes

- **auth:** return null user and session for email_change
single-confirmation verifyOtp
([#2378](supabase/supabase-js#2378))
- **release:** mark @supabase/tracing private and snapshot it for JSR
([#2370](supabase/supabase-js#2370))
- **storage:** make StreamDownloadBuilder implement Promise and memoize
executor ([#2367](supabase/supabase-js#2367))

### ❤️ Thank You

- Claude Sonnet 4.5
- Guilherme Souza
- Katerina Skroumpelou @mandarini
- oniani1

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.

Bug: StreamDownloadBuilder is missing Promise interface methods and re-runs executor on every await

2 participants