You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
catch EBADF exceptions from Lwt_process.with_process_full
Summary:
we're seeing exceptions like this:
```
Failed to initialize watchman: Unix.Unix_error(Unix.EBADF, "close", "")
Raised by primitive operation at Lwt_unix.self_result in file "src/unix/lwt_unix.cppo.ml", line 237, characters 14-31
Re-raised at Watchman.get_sockname.(fun) in file "flow/src/hack_forked/watchman/watchman.ml", line 381, characters 2-934
Re-raised at FileWatcher.WatchmanFileWatcher.watchman#wait_for_init.go_exn.(fun) in file "flow/src/monitor/fileWatcher.ml", line 534, characters 10-1023
```
`Watchman.get_sockname` calls `LwtSysUtils.exec` which calls `Lwt_process.with_process_full`. `with_process_full` does an `Lwt.finally` to make sure it calls `process#close`. `close` is throwing because the process's fd is invalid (perhaps already closed).
The stack traces aren't much to go on, but I suspect this is happening on exceptions. The file descriptor shouldn't be invalid otherwise. That means there's an underlying exception that's getting hidden by the `finally` also throwing.
So, here we ignore `EBADF` exceptions from the `close` and rethrow the original exception.
I also filed ocsigen/lwt#956 to discuss doing this upstream.
Changelog: [internal]
Reviewed By: samwgoldman
Differential Revision: D37420401
fbshipit-source-id: 0e7ddf41a3f4d13290e49c692be66723eda1f227
0 commit comments