[scramjet/core] fix data uri -> blob pipeline leaking memory#74
Merged
Conversation
There was a problem hiding this comment.
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
$fakedataurlquery param flag when rewriting oversizeddata:URLs intoblob: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) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.