* True when an error is OS watch/file-descriptor exhaustion (EMFILE/ENFILE). * Prefers the structured `err.code`; falls back to message matching ONLY when * no code is present (some platforms surface a bare Error from `fs.watch`).
(err: unknown)
| 99 | * no code is present (some platforms surface a bare Error from `fs.watch`). |
| 100 | */ |
| 101 | function isWatchResourceExhaustion(err: unknown): boolean { |
| 102 | const e = err as NodeJS.ErrnoException | undefined; |
| 103 | if (e?.code === 'EMFILE' || e?.code === 'ENFILE') return true; |
| 104 | if (!e?.code && e?.message) { |
| 105 | return /EMFILE|ENFILE|too many open files/i.test(e.message); |
| 106 | } |
| 107 | return false; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * True when an error is Linux inotify *watch-count* exhaustion. `fs.watch` |
no outgoing calls
no test coverage detected