Most Popular Posts

Apr 18, 2014

OneSql Client – Breaking Change: Timeout Options Removed

This is an advance notice of an upcoming breaking change.


The following properties of type OneSql.Client.Options have been removed:

  • ConnectTimeout
  • CommandTimeout
  • DefaultConnectTimeout
  • DefaultCommandTimeout

OneSql Client operations will complete only based on [MS-TDS] protocol flows, not based on any timeout.


0.3 and above.


The purpose of timeouts is to give control back to the app when an operation takes too long to complete. This is mainly useful in synchronous API where the client thread is blocked on the operation.

In asynchronous API, like OneSql Client, the calling thread is never blocked. It is a developer’s choice whether to await the completion of the operation or to perform some other action.

The purpose of the timeout options was to provide a “timed await” mechanism that is common for all languages.However, the current implementation is incorrect – it leaves the SqlClient (and its underlying TdsClient) in a state that prevents further usage.

The cost of cleaning up SqlClient’s state exceeds the value of the feature by far. Moreover, that cleanup (which involves a new request to the server as well as receiving its response) may take a time that is long enough to defeat the purpose of the timeout. Therefore, timeouts have been discontinued.

Action Needed

Remove code that is setting (or getting) the above properties explicitly. Otherwise, when you upgrade your copy of OneSql Client, your app won’t compile.

If you want to get control after a certain time before the operation has finished, use standard Windows RT mechanisms specific to the language of your app:


var cts = new CancellationTokenSource(secs * 1000);
await sqlClient.XxxAsync(…).AsTask(cts);


var sqlPromise = sqlClient.XxxAsync();
WinJS.Promise.timeout(secs * 1000, sqlPromise).then(…, …);

When you get control before the operation has finished, the SqlClient will be in a dirty state. You won’t be able to continue using it. Dispose of it. Any uncommitted transactions will be rolled back. Create a new SqlClient, connect it to the SQL Server, and decide how to continue.

No comments: