I have 2 fetch functions calling the same PHP Script. The whole content of the PHP-Script is the following:
<?php
session_write_close();
sleep(10);
session_write_close();
is only there to make sure the Session is really closed. However the first Script finishes after ~10 Seconds and the second Script after ~20 Seconds:
Why is Script 1 blocking Script 2?
For the sake of completeness here is the JavaScript:
async function test() {
fetch('api/v1/test')
fetch('api/v1/test')
}
test();
2
Answers
For everyone else who faces the same problem: If you develop locally on the Built-In web server you need the following setting:
PHP_CLI_SERVER_WORKERS
Windows is currently not supported and PHP >=7.4 is needed.
Link to the documentation: Documentation
As per the comment above, I am unable to replicate the
blocking
behaviour you mention.Using essentially the same function and sending a minimal GET request to the PHP endpoint (in this case the same page ) that does essentially the same as the original the requests all return content almost together.
This yields, for example: