fsprojects / FSharp.Configuration

The FSharp.Configuration project contains type providers for the configuration of .NET projects.
http://fsprojects.github.io/FSharp.Configuration/
Other
114 stars 63 forks source link

tryReadNonEmptyTextFile Loops Indefinitely if File is not Found #96

Open HoraceGonzalez opened 8 years ago

HoraceGonzalez commented 8 years ago

Description

FSharp.Configuration.Helper.File.tryReadNonEmptyTextFile loops indefinitely if file is not found.

https://github.com/fsprojects/FSharp.Configuration/blob/46d6db2b88b7445497314aa4d6a33772223c88c5/src/FSharp.Configuration/TypeProviders.Helper.fs#L218-L233

Repro steps

open FSharp.Configuration

type Config = YamlConfig<YamlText=@"SampleConfig:",ReadOnly=true>

// loops indefinitely
Config().Load("./some/nonexistent/config.yml")

Expected behavior

tryReadNonEmptyTextFile eventually stops trying to load the file.

Actual behavior

Sample fsi output:

Attempt 1 of 5: cannot read ./some/nonexistent/config.yml. Sleep for 1 sec, then retry...
Attempt 2 of 5: cannot read ./some/nonexistent/config.yml. Sleep for 1 sec, then retry...
Attempt 3 of 5: cannot read ./some/nonexistent/config.yml. Sleep for 1 sec, then retry...
Attempt 4 of 5: cannot read ./some/nonexistent/config.yml. Sleep for 1 sec, then retry...
Attempt 5 of 5: cannot read ./some/nonexistent/config.yml. Sleep for 1 sec, then retry...
Attempt 6 of 5: cannot read ./some/nonexistent/config.yml. Sleep for 1 sec, then retry...
Attempt 7 of 5: cannot read ./some/nonexistent/config.yml. Sleep for 1 sec, then retry...
Attempt 8 of 5: cannot read ./some/nonexistent/config.yml. Sleep for 1 sec, then retry...