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
{{ message }}
Repository navigation
S3Client writes empty file for HTMLRewriter transformed fetch Response #19305
constr2=newS3Client();// setup r2 paramsdescribe("S3Client",()=>{test("save webpage to R2 via HTMLRewriter",async()=>{constresponse=awaitfetch("https://bun.sh");constrewriter=newHTMLRewriter();constrewrittenResponse=rewriter.transform(response);awaitr2.write("index.html",rewrittenResponse);consttext=awaitr2.file("index.html").text();expect(text).not.toBeEmpty();});test("save webpage to R2",async()=>{constresponse=awaitfetch("https://bun.sh");awaitr2.write("index2.html",response);consttext=awaitr2.file("index2.html").text();expect(text).not.toBeEmpty();});});
The first test fails and it should not.
What is the expected behavior?
I'd expect to be able to fetch some HTML, run it through a HTMLRewriter and save that back to R2 via the S3Client.
If this shouldn't work, then it ought to error rather then create an empty file on R2.
What do you see instead?
The client will occasionally (but not always) write empty files.
Additional information
I'm unsure if this is only an issue with Cloudflare R2, I've not tried the others.
Converting the transformed response to text first will workaround the issue. r2.write(path, await response.text()
Writing to a local file with Bun.file (instead of S3Client) works as expected.
Activity
HTMLRewriter: stream the input and output instead of buffering
HTMLRewriter: stream the input and output instead of buffering
HTMLRewriter: stream the input and output instead of buffering
HTMLRewriter: stream the input and output instead of buffering
HTMLRewriter: stream the input and output instead of buffering
HTMLRewriter: stream the input and output instead of buffering
HTMLRewriter: stream the input and output instead of buffering
HTMLRewriter: write output to a ByteStream and feed the rewriter per …
HTMLRewriter: route all input through the JS pump; drop the re-entran…
HTMLRewriter: write output to a ByteStream and feed the rewriter per …
HTMLRewriter: route all input through the JS pump; drop the re-entran…
HTMLRewriter: stream through SinkHandle/SourceHandle; suspend async h…
HTMLRewriter: stream through SinkHandle/SourceHandle; suspend async h…