Skip to content

Commit 4b94b07

Browse files
committed
work around blob url jank breaking anubis
1 parent ab34701 commit 4b94b07

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/client/shared/blob.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,18 @@ export default function (client: ScramjetClient) {
1515

1616
client.Proxy("URL.revokeObjectURL", {
1717
apply(ctx) {
18-
ctx.args[0] = unrewriteBlob(ctx.args[0]);
18+
setTimeout(() => {
19+
// scramjet rewrites blob urls to pass through the service worker first
20+
// this is neccesary if rewrites need to be applied to the blob
21+
// the issue is that if you call revokeObjectURL immediately after using the blob
22+
// the service worker will not have had time to download the blob
23+
// for some reason this is not an issue natively
24+
// simple delay is enough
25+
// TODO: find a way to make this not necessary
26+
ctx.args[0] = unrewriteBlob(ctx.args[0]);
27+
ctx.call();
28+
}, 1000);
29+
ctx.return(undefined);
1930
},
2031
});
2132
}

0 commit comments

Comments
 (0)