Skip to content

[scramjet/core] fix data uri -> blob pipeline leaking memory#74

Merged
velzie merged 3 commits into
HeyPuter:mainfrom
Percslol:fix-mem-leak
May 24, 2026
Merged

[scramjet/core] fix data uri -> blob pipeline leaking memory#74
velzie merged 3 commits into
HeyPuter:mainfrom
Percslol:fix-mem-leak

Conversation

@Percslol
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a memory leak when very large data: URLs are rewritten into blob: URLs to avoid Chrome URL-length limits, by tagging those synthetic blob URLs and revoking them after the fetch completes.

Changes:

  • Add a $fakedataurl query param flag when rewriting oversized data: URLs into blob: URLs.
  • Parse and plumb the new flag through ScramjetFetchParsed.
  • Revoke the generated blob: object URL in the blob/data fetch handler when the flag is present.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
packages/scramjet/packages/core/src/shared/rewriters/url.ts Adds a query flag when converting long data: URLs to blob: URLs.
packages/scramjet/packages/core/src/fetch/parse.ts Introduces the new query param key and parses it into ScramjetFetchParsed.
packages/scramjet/packages/core/src/fetch/index.ts Extends the parsed fetch interface with isFakeDataURL.
packages/scramjet/packages/core/src/fetch/fetch.ts Revokes object URLs for flagged synthetic data:blob: requests to prevent leaks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (url.length + context.prefix.href.length + BUFFER > URL_MAX_LENGTH) {
const { objectUrl } = dataToBlob(url);
return context.prefix.href + rewriteBlob(objectUrl, context, meta);
return context.prefix.href + rewriteBlob(objectUrl, context, meta) + "?"+QP.fakeDataURL+"=1";
Comment on lines 276 to 279
}

if (parsed.isFakeDataURL) URL.revokeObjectURL(dataUrl)

@velzie velzie merged commit 26e317d into HeyPuter:main May 24, 2026
1 check passed
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.

3 participants