Skip to content

PollWatcher: Ignore IO "file not found" exceptions when accessing entry metadata?🥺  #581

@earshinov

Description

@earshinov

For local development, we are running our Django app inside a Linux Docker container, launched from Windows host with help of WSL2, with sources typically mounted from the Windows file system. We are using watchfiles + django_watchfiles instead of Django's built-in reloader. Watchfiles uses notify under the hood (source). Thanks to this code in watchfiles, it understands that it is launched from a Windows host and falls back to PollWatcher (👌).

We are facing an issue that notify hits an exception (also bringing down the Django app and the Docker container) when we launch mypy in the same running container:

_rust_notify.WatchfilesRustInternalError: error in underlying watcher: IO error for operation on /opt/project/.mypy_cache/3.10/iniconfig/__init__.meta.json.894e30fd1ecd2163: No such file or directory (os error 2) about ["/opt/project/.mypy_cache/3.10/iniconfig/__init__.meta.json.894e30fd1ecd2163"]

I am mediocre at best in Rust, but I assume that this exception is coming from here:

data_builder.emitter.emit_io_err(e, path);

Could we perhaps have "Not found" errors ignored?

System details

Software

watchfiles 0.21 (latest release)
notify 5.1.0 (source)

I see the same code in latest notify here in the repo, so I guess we would have the same problem with watchfiles rebuilt with latest notify.

OS

Host: Windows 11 x64 Version 23H2 (0S Build 22631.3296)

> wsl cat /proc/version
Linux version 5.10.102.1-microsoft-standard-WSL2 (oe-user@oe-host) (x86_64-msft-linux-gcc (GCC) 9.3.0, GNU ld (GNU Binutils) 2.34.0.20200220) #1 SMP Wed Mar 2 00:30:59 UTC 2022

Docker container: python:3.11-bullseye-slim

What you expected

Errors when accessing metadata of a presumably changed file being silently ignored

What happened

A chain reaction notify ⇒ watchfiles ⇒ Django app ⇒ Docker container 💀

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions