Skip to content

Server shutdown and preventing hanging streaming calls #2357

Open
@JamesNK

Description

@JamesNK

When a server shuts down it gives a grace period to requests to finish. However, there is no indication to requests that they should finish, i.e. ServerCallContext.CancellationToken isn't raised. To find out about cancellation, someone needs to look at IHostApplicationLifetime.ApplicationStopping.

Knowing about app shutdown is important for long running gRPC streaming calls that are watching ServerCallContext.CancellationToken to figure out if they should stop. They could wait until the shutdown timeout limit is reached, delaying app shutdown and preventing a completely graceful shutdown.

Ideas:

  1. Add a RaiseStreamingCancellationOnStopping option to gRPC server. ServerCallContext.CancellationToken would automatically be canceled on app stopping. Having raised the cancellation token could create confusion about whether a call is still allowed to write to the response stream. This is problematic.
  2. Documentation. Discuss shutdown and using IHostApplicationLifetime.ApplicationStopping in an app to end streaming calls on stopping.

Documentation is probably the safer course of action.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions