Why does RemoteDatabsaeChanges has DisposeAsync, and other pro dev tips

time to read 2 min | 218 words

The following piece of code is taken from the RavenDB’s RemoteDatabaseChanges class, which implements the client side behavior for the RavenDB Changes API:


As you can see, we are doing something really strange here, DisposeAsync().

The reason it is there is that we need to send a command to the server to tell it to disconnect the connection from its end. Sure, we can just abort the request from our end (in fact, we are doing that), but only after we have tried to get the server to do this.

Why are we doing this?

The answer is quite simple. We want good Fiddler support.

By sending the disconnect command, we ensure that the connection will be properly closed, and Fiddler can then show the content, like so:

Being able to look at those (even if only after the connection has been closed) is invaluable when doing diagnostics, debugging or just wanting to take a peek.

On the hand, if we weren’t doing this, we would get 502 or 504 errors from Fiddler, which is annoying and opaque. And that isn’t a good way to create a good feel for people trying out your products.