Class ServerRequestScheduling
How an RDCore server schedules the requests and notifications it receives.
public static class ServerRequestScheduling
- Inheritance
-
ServerRequestScheduling
- Inherited Members
Fields
NoRequestBudget
How long OmniSharp lets a request or a notification that an RDCore server or client received run before it gives up on it: longer than anything it receives runs.
public static readonly TimeSpan NoRequestBudget
Field Value
Remarks
OmniSharp gives up on whatever it received that still runs once MaximumRequestTimeout has passed, five minutes
by default. A request is then answered RequestCancelled (-32800), which says that its sender cancelled it, and a notification is dropped.
Five minutes is not long enough for some requests: a diagnostics pull of a large workspace on a loaded machine, or a program that runs, or waits at a
MsgBox, that long. How busy the machine is then decides the answer, and a client that is told its pull was cancelled does not pull again. A
request is cancelled by its sender, which sends $/cancelRequest for it.
OmniSharp's timer cannot be turned off. An infinite timeout is taken for none at all, so every request is answered RequestCancelled at
once; and a delay longer than a timer accepts throws, so the request is never answered. This is the longest delay every timer accepts:
MaxValue milliseconds, about 24.8 days.
Methods
WithEveryRequestAnswered(LanguageServerOptions)
Has the server answer every request it receives, whatever notifications arrive while the request runs.
public static LanguageServerOptions WithEveryRequestAnswered(this LanguageServerOptions options)
Parameters
optionsLanguageServerOptionsThe server's options.
Returns
- LanguageServerOptions
The same options.
Remarks
OmniSharp runs a request such as textDocument/diagnostic in parallel, and a notification such as textDocument/didOpen in order. By
default, a notification that arrives while requests run abandons them, and answers them ContentModified (-32801). In OmniSharp 0.19.9 a
request whose handling starts just as that happens is answered nothing at all, and its client waits forever, with the server idle: HexIDE's client
saw it on a quick run of didOpens, each followed by its diagnostics pull (findings desk #31).
With this, a request runs to its end and is answered. What it answers for a document that has moved on in the meantime is its handler's to decide: the diagnostics pull drops a report of a version that is no longer the document's.
The notification waits for the requests that run. A request that would make it wait long gives way to a change to its document instead, answered
ContentModified as the change arrives (WhileCurrentAsync<T>(Uri, CancellationToken, Func<CancellationToken, Task<T>>)).
Nor is a request given up on because it runs long: it is answered whatever it takes (WithNoRequestBudget<T>(T)).
WithLifecycleReceiver(LanguageServerOptions)
Has the server read what it receives as an RDCore server reads it: an exit notification is let through before the server is initialized,
and once it is, a request marked HandledOnArrivalAttribute is handled as it arrives.
public static LanguageServerOptions WithLifecycleReceiver(this LanguageServerOptions options)
Parameters
optionsLanguageServerOptionsThe server's options.
Returns
- LanguageServerOptions
The same options.
Remarks
Every server built on RDCoreServerApp is configured with this. A server that builds its OmniSharp language server by itself, and serves requests marked HandledOnArrivalAttribute, calls it so that those requests are handled while a request that runs a program runs: without it they are scheduled after that request, and a program that never ends can be neither paused nor ended.
Before the initialize request completes, a request other than initialize is answered ServerNotInitialized (-32002) and a
notification other than exit is dropped (LSP 3.17, Server lifecycle, Initialize Request). OmniSharp's own reader of
incoming messages drops an early exit as well, and a client that ends the server before it initializes it waits for a process that does not
end.
The locale of the initialize request (LSP 3.17 InitializeParams.locale) is kept as it arrives: OmniSharp 0.19.9
reads the request without it.
OmniSharp keeps the first reader of incoming messages it is given: call this before anything else registers one.
WithNoRequestBudget<T>(T)
Sets the options so that OmniSharp lets a request or a notification that a server or a client received run to its end, however long it runs (NoRequestBudget).
public static T WithNoRequestBudget<T>(this T options) where T : IJsonRpcServerOptions
Parameters
optionsTThe options.
Returns
- T
The same options.
Type Parameters
TThe options: a language server's, a language client's or a debug adapter's.
Remarks
Every server built on RDCoreServerApp and every client built on RDCoreClientApp is configured with this. A server or a client
that builds its OmniSharp options itself (a debug adapter, a client of its own) calls it so that what it receives is not answered
RequestCancelled after five minutes.