Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL.revokeObjectURL fails for blobs ("relative URL without a base") #23085

Closed
FND opened this issue Mar 26, 2024 · 2 comments
Closed

URL.revokeObjectURL fails for blobs ("relative URL without a base") #23085

FND opened this issue Mar 26, 2024 · 2 comments

Comments

@FND
Copy link

FND commented Mar 26, 2024

Version: Deno 1.41.3

Reduced test case:

// sample.js
const code = 'console.log("hello world");';
const blob = new Blob([code], { type: "text/javascript" });
const worker = new Worker(URL.createObjectURL(blob), { type: "module" });
URL.revokeObjectURL(blob);

(Line 4 is optional; the error occurs even without instantiating a worker.)

$ deno run sample.js
hello world
error: Uncaught (in promise) URIError: relative URL without a base
URL.revokeObjectURL(blob);
    ^
    at Function.revokeObjectURL (ext:deno_web/09_file.js:703:3)
    at file:///…/sample.js:4:5

(FWIW, deferring revokeObjectURL invocation via setTimeout doesn't seem to make a difference.)

I don't see any obvious connection to related issues.

$ deno --version
deno 1.41.3 (release, aarch64-apple-darwin)
v8 12.3.219.9
typescript 5.3.3
@xBZZZZ
Copy link

xBZZZZ commented Mar 26, 2024

URL.revokeObjectURL takes blob url, not Blob object:

// sample.js
const code = 'console.log("hello world");';
const bloburl = URL.createObjectURL(new Blob([code], { type: "text/javascript" }));
const worker = new Worker(bloburl, { type: "module" });
URL.revokeObjectURL(bloburl);

@FND
Copy link
Author

FND commented Mar 26, 2024

Oh wow, you're right; that makes sense! Guess I've been doing this wrong the entire time because browsers don't seem to give any indication when attempting to revoke a blob instead - thanks, Deno!

@FND FND closed this as completed Mar 26, 2024
FND added a commit to FND/prepitaph that referenced this issue Mar 26, 2024
as exposed by Deno: denoland/deno#23085

this is an annoyingly subtle mistake, but doesn't quite warrant an
update announcement
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

No branches or pull requests

2 participants