Shutdown and Draining

Learn more about the default behavior of our SDK if the application shuts down unexpectedly.

The default behavior of most SDKs is to send out events over the network asynchronously in the background. This means that some events might be lost if the application shuts down unexpectedly. The SDKs provide mechanisms to cope with this.

The close method optionally takes a timeout in milliseconds and returns a promise that resolves when all pending events are flushed, or the timeout kicks in.

Sentry.close(2000).then(function () {
  // perform something after close

After a call to close, the current client cannot be used anymore. It's important to only call close immediately before shutting down the application.

Alternatively, the flush method drains the event queue while keeping the client enabled for continued use.

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").