Using RavenDb FilesStore from F# Interactive hangs

101 Views Asked by At

I am trying to access a ravendb file system from an f# script.

I have this code:

#r "libs/Raven.Abstractions.dll"
#r "libs/Raven.Client.Lightweight.dll"

open Raven.Client.FileSystem

let fs = new FilesStore(Url = "http://localhost:8080", DefaultFileSystem = "TestFS")
let s = fs.Initialize() 

printfn "%A" s.Identifier

if I execute the script using fsi on the file or by compiling the script with fsc it runs and prints http://localhost:8080 as expected but if I execute it in F# interactive inside VisualStudio it just hangs on the fs.Initialize() line

Now, if I call the Initialize method with false (ensureFileSystemExists) it runs ok in interactive.

Why does it work like this?

this is a piece of the FilesStore.cs code:

if (ensureFileSystemExists && string.IsNullOrEmpty(DefaultFileSystem) == false)
{
    try
    {
        AsyncFilesCommands.ForFileSystem(DefaultFileSystem)
                                      .EnsureFileSystemExistsAsync()
                                      .Wait();
    }
    catch(Exception)
    {
        if (failIfCannotCreate)
            throw;
    }
}

the ensureFileSystemExists variable is the false I pass on the second call to Initialize (the one that works on VS' F# interactive)

1

There are 1 best solutions below

0
On BEST ANSWER

Update to the latest build, it should resolve this issue. The underlying issue is the TPL scheduler used by default.