You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey! I've ran into an interesting edge case it seems. Async Handlers are supported with HtmlRewriter, however if you try to use the cache api inside of an async handler while caching the response itself, it just loads forever/seems to deadlock itself. No errors in console. This is reproducible both in local dev and deployed on Cloudflare Workers.
Min. Reproducible Example:
exportdefault{asyncfetch(request,env,ctx){letmyResponse=newResponse("<!DOCTYPE html><title>x</title><h1>test</h1>",{headers: {"content-type": "text/html",}})myResponse=newHTMLRewriter().on('h1',{asyncelement(e){awaitcaches.default.put("https://example.com/dummy",newResponse("hey!"))// I know this wouldn't get cached, just min to reproduce issuee.setInnerContent('Rewritten');}}).transform(myResponse);awaitcaches.default.put("https://example.com/raw",myResponse.clone());returnmyResponse;},};
(of course in a larger example I was fetching, changing response headers and caching/using body/using ctx.waitUntil)
The .clone itself doesn't block, I tried doing it outside of it. If I force the rewriter to run and pull the response into memory that works around it:
Hey! I've ran into an interesting edge case it seems. Async Handlers are supported with HtmlRewriter, however if you try to use the cache api inside of an async handler while caching the response itself, it just loads forever/seems to deadlock itself. No errors in console. This is reproducible both in local dev and deployed on Cloudflare Workers.
Min. Reproducible Example:
(of course in a larger example I was fetching, changing response headers and caching/using body/using ctx.waitUntil)
The .clone itself doesn't block, I tried doing it outside of it. If I force the rewriter to run and pull the response into memory that works around it:
The text was updated successfully, but these errors were encountered: