Why is :list_dir wrapped in a :gen_server call in Path's Wildcard module?

On Windows at times, Path.wildcard( "/a/b/*/c/d" ) will fail due to time out. Looking into why, I found a :gen_server.call(:file_server_2, tuple) with no configurable timeout in elixir’s path.ex.
However I can simply get the same result using erlang’s :filelib.wildcard( '/a/b/*/c/d' )
I would like to know why the GenServer wrapper in path.ex: am I walking into a snake’s nest by using :filelib directly? Is the intent to single-process access the filesystem, or else? Or is the purpose simply to prevent elixir halting on long filesystem access and have it abort before erlang will?

The implementations are relatively the same. Path.wildcard also uses :filelib. Calling :filelib directly calls :file that calls a GenServer but with the timeout of infinity. We should fix this on the Elixir side of things.

5 Likes