| 440 | */ |
| 441 | // @ts-expect-error - PromiseLike is a subset of Promise |
| 442 | public async flush(timeout?: number): PromiseLike<boolean> { |
| 443 | const transport = this._transport; |
| 444 | |
| 445 | // Emit `flush` unconditionally so weight-based log/metric flushers drain |
| 446 | // their buffers and clear their idle timers, even when no transport is |
| 447 | // configured (e.g. no DSN). |
| 448 | this.emit('flush'); |
| 449 | |
| 450 | if (!transport) { |
| 451 | return true; |
| 452 | } |
| 453 | |
| 454 | const clientFinished = await this._isClientDoneProcessing(timeout); |
| 455 | const transportFlushed = await transport.flush(timeout); |
| 456 | |
| 457 | return clientFinished && transportFlushed; |
| 458 | } |
| 459 | |
| 460 | /** |
| 461 | * Flush the event queue and set the client to `enabled = false`. See {@link Client.flush}. |