LibWeb: HTTP fetch request from inside a Worker hangs
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!
-
cdinto the folder containing the above files - Start a HTTP server with
python3 -m http.server 8080 - Visit
http://localhost:8080/worker-fetch-test.htmlin 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.
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
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.
I am currently not able to reproduce this issue in any way with the instructions above. Running build from a0f3099
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"