onDispose method
Release what this host holds beyond its sessions and plugins.
Runs while the event stream is still open, so a failure here can still be reported.
Implementation
@protected
@override
Future<void> onDispose() async {
await _registrySnapshots?.cancel();
_registrySnapshots = null;
// The registry closes what it holds open, and a durable one writes what
// is still waiting first. Walking `documentIds` here instead would read
// every document on disk back into memory just to dispose it, and would
// leave the registry holding disposed documents.
try {
await _serverRegistry.close();
} catch (e) {
addServerEvent(
ServerEvent(
type: ServerEventType.error,
message: 'Error closing the document registry: $e',
),
);
}
}