Yarn dev makes code execute twice

When I run the yarn dev command and add the following code to the index.php file of my theme:

file_put_contents('test.txt', $_SERVER['REQUEST_URI'] . PHP_EOL, FILE_APPEND | LOCK_EX);

Each request creates two new entries in the test.txt file. This happens even if I stop watching.

These are the two entries:

/
/bud/hot

To stop the duplicate requests, I need to run yarn build.

This makes it quite annoying to work with Xdebug because right after I resume the program or stop debugging in the PhpStorm debug tab, it runs again due to that second request.

Is there a way to make it so that it runs only once, even when using the yarn dev command?
Isn’t it a big issue in general, since each request is done twice during development, or is it just a problem with my setup?

My setup uses a bedrock + plain sage theme