Bug can occur when using the following code to refer to your file system, for example to save a file to your file system:
$path_to_files = file_create_url("public://");
Instead, use this:
$path_to_files = \Drupal::service('file_system')->realpath();