LadybirdBrowser/ladybird

LibWeb: HTTP fetch request from inside a Worker hangs

tcl3 opened this issue · 0 comments

tcl3 commented

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.

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

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