Shutdown and Draining
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.
Copied
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.
- Package:
- npm:@sentry/gatsby
- Version:
- 8.24.0
- Repository:
- https://github.com/getsentry/sentry-javascript