Skip to content

fix(event): save inline rx.download data through a blob url - #7853

Merged
FarhanAliRaza merged 11 commits into
reflex-dev:mainfrom
abulvenz:download-blob-url
Nov 30, 2026
Merged

FarhanAliRaza merged 11 commits into
reflex-dev:mainfrom
abulvenz:download-blob-url

Conversation

@abulvenz

@abulvenz abulvenz commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

iOS WebKit (Safari, every other iOS browser and installed PWAs) ignores the download attribute of data: urls and only displays the file instead of saving it. rx.download(data=...) always produces a data: url, so it never saves a file on iOS.

The _download event now turns a data: url into a blob: url before clicking the link, and attaches the link to the document first. It decodes the data itself, because a connect-src policy can block fetching a data: url. A download without a filename is still named download with the extension of its type. Regular urls are downloaded from the same url with the same name.

Tests: a Playwright test downloads inline text from a frontend event, data: urls from state, bytes from a backend event, and data without a filename. It asserts the blob url, file name and exact content, under a connect-src policy that blocks fetching data: urls. It fails without the fix.

View guided diff

@abulvenz
abulvenz requested a review from a team as a code owner November 11, 2026 22:00
iOS WebKit (every iOS browser and installed PWAs) ignores the download
attribute of data: urls and only shows the file as text. The _download
event turns a data: url into a blob: url and attaches the link to the
document before clicking it.
@greptile-apps

greptile-apps Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; the previous file-type issue is fixed.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous file-type issue is fixed.

Summary

rx.download converts inline data into a temporary blob URL so iOS browsers can save the file.

  • Inline downloads turn data URLs into files browsers can save.

The previous file-type finding is fixed. No new actionable issues were found in the changes since the last review. Tests were inspected, not run.

Reviews (10) · Last reviewed commit: "Default a data: url without a media type..." · Reviewed by Greptile

@codspeed

codspeed Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 6.38%

2 warnings

⚠️ 19 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 3 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

❌ 3 regressed benchmarks
✅ 143 untouched benchmarks
⏩ 8 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_route_matching[1000] 90 ms 96.8 ms -6.95%
❌ test_route_matching[100] 9.4 ms 10.1 ms -6.79%
❌ test_route_matching[10] 1.2 ms 1.3 ms -5.38%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing abulvenz:download-blob-url (614e158) with main (6f5c39c)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

A connect-src policy that does not allow data: urls blocks fetching one,
so the _download event decodes the base64 or percent-encoded data itself
before building the blob: url.

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

@FarhanAliRaza FarhanAliRaza added the bug Something isn't working label Nov 12, 2026 — with ChatGPT Codex Connector
…load like fetch

A data: url handed to rx.download through a Var is passed on unchanged and
may carry a fragment or percent-encode its base64 body. Drop the fragment
and percent-decode the body before base64-decoding it, as the data url
processor does.
@abulvenz

Copy link
Copy Markdown
Contributor Author

@codspeedbot fix this regression

@abulvenz

Copy link
Copy Markdown
Contributor Author

The CodSpeed regression in test_route_matching[100] (−5.9%) is unrelated to this change: the PR only touches state.js, an integration test and a news fragment, none of which run in that benchmark. It matches the flaky ±5.5–5.9% swings of route_matching that #7878 describes, which come from the benchmark measuring a few lru_cache hits

@FarhanAliRaza FarhanAliRaza added the on deck PRs lined up to review / merge next label Nov 23, 2026
- A download without a filename gets "download" plus the type's extension,
  not the blob url's uuid.
- Percent escapes decode with unescape instead of a callback per escape:
  a 1 MB CSV var decodes in 10 ms instead of 83 ms.
- A data: url without a comma stays as it is instead of saving its own text.
- The decoder moves to dataUrlToBlob, out of applyEvent.

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 2 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

View guided diff | Re-trigger cubic

A data: url such as "data:,hello" or "data:;base64,..." has no media type,
and fetch decodes it as text/plain;charset=US-ASCII. dataUrlToBlob
produced a Blob with an empty type instead, so a download without a
filename lost its .txt extension. Apply the same default, and prefix
text/plain when the url supplies only parameters such as a charset.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ESN8DiGC3xZjMWMjXyvzqa
@FarhanAliRaza
FarhanAliRaza merged commit 7ee72a1 into reflex-dev:main Nov 30, 2026
170 of 171 checks passed
FarhanAliRaza pushed a commit that referenced this pull request Nov 30, 2026
main's #7853 adds dataUrlToBlob to state.js, which every stateful app
ships: el_stateful js_gzip is 155,207 B against a 155,000 B limit that had
12 B of headroom. The limit becomes the measured value plus 5 %, like the
other size budgets.

Claude-Session: https://claude.ai/code/session_014AwvTPMyGMj9KHaq66r64v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ios on deck PRs lined up to review / merge next

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants