ladybird icon indicating copy to clipboard operation
ladybird copied to clipboard

LibWeb: HTTP fetch request from inside a Worker hangs

Open tcl3 opened this issue 1 year ago • 3 comments

Currently any fetch request to a http or https address happening inside a Worker will hang indefinitely.

This can be reproduced by following these steps:

  • Put the following files into a folder:

worker-fetch-test.html:

<!DOCTYPE html>
<script>
    const worker = new Worker("worker-fetch-test.js");
    worker.onmessage = (evt) => {
        console.log(`Fetch request completed. Content: ${evt.data}`);
    };
</script>

worker-fetch-test.js:

fetch("./test.file")
    .then(response => response.text())
    .then(text => self.postMessage(text));

test.file:

Fetch works correctly!
  • cd into the folder containing the above files
  • Start a HTTP server with python3 -m http.server 8080
  • Visit http://localhost:8080/worker-fetch-test.html in Ladybird
  • The message "Fetch request completed. Content: Fetch works correctly!" should be printed to the console, but currently nothing happens. NOTE: This behavior seems to occur intermittently. You may need to refresh the page to get it to hang.

The hang occurs because EAGAIN is returned when the response data is read.

I previously attempted to fix this issue in d0f88d49585f147164c676e2615767cba98d5fa but the change ended up having to be reverted.

tcl3 avatar Jun 17 '24 15:06 tcl3

This doesn't appear to hang anymore (at least I cannot reproduce it). However, the request does not succeed due to a CORS failure

Unhandled JavaScript exception (in promise): [TypeError] Request with 'cors' response tainting failed CORS check

braydnm avatar Jul 04 '24 02:07 braydnm

This issue still occurs for me with the changes from #408 applied. I've updated the description to make it clear that the issue occurs intermittently.

tcl3 avatar Jul 04 '24 17:07 tcl3

I am currently not able to reproduce this issue in any way with the instructions above. Running build from a0f3099

DavidLobster avatar Mar 26 '25 14:03 DavidLobster

I too can not reproduce it (with 3f5bc023e28d2e3fd86114cc0c333da22142e0b8). The fetch works without noticeable delay.

Ladybird logs

1684032.182 WebContent(588905): (js log) "Fetch request completed. Content: Fetch works correctly!\n"