Skip to content

Commit 554bb5b

Browse files
committed
fix to promise like
1 parent 43af3ba commit 554bb5b

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

packages/core/src/client.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
316316
* @returns A promise that will resolve with `true` if all events are sent before the timeout, or `false` if there are
317317
* still events in the queue when the timeout is reached.
318318
*/
319-
public async flush(timeout?: number): Promise<boolean> {
319+
// @ts-expect-error - PromiseLike is a subset of Promise
320+
public async flush(timeout?: number): PromiseLike<boolean> {
320321
const transport = this._transport;
321322
if (!transport) {
322323
return Promise.resolve(true);
@@ -338,7 +339,8 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
338339
* @returns {Promise<boolean>} A promise which resolves to `true` if the flush completes successfully before the timeout, or `false` if
339340
* it doesn't.
340341
*/
341-
public async close(timeout?: number): Promise<boolean> {
342+
// @ts-expect-error - PromiseLike is a subset of Promise
343+
public async close(timeout?: number): PromiseLike<boolean> {
342344
const result = await this.flush(timeout);
343345
this.getOptions().enabled = false;
344346
this.emit('close');
@@ -873,7 +875,8 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
873875
/**
874876
* Send an envelope to Sentry.
875877
*/
876-
public async sendEnvelope(envelope: Envelope): Promise<TransportMakeRequestResponse> {
878+
// @ts-expect-error - PromiseLike is a subset of Promise
879+
public async sendEnvelope(envelope: Envelope): PromiseLike<TransportMakeRequestResponse> {
877880
this.emit('beforeEnvelope', envelope);
878881

879882
if (!this._isEnabled() || !this._transport) {

packages/node-core/src/sdk/client.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ export class NodeClient extends ServerRuntimeClient<NodeClientOptions> {
7878
}
7979

8080
/** @inheritDoc */
81-
public async flush(timeout?: number): Promise<boolean> {
81+
// @ts-expect-error - PromiseLike is a subset of Promise
82+
public async flush(timeout?: number): PromiseLike<boolean> {
8283
await this.traceProvider?.forceFlush();
8384

8485
if (this.getOptions().sendClientReports) {
@@ -89,7 +90,8 @@ export class NodeClient extends ServerRuntimeClient<NodeClientOptions> {
8990
}
9091

9192
/** @inheritDoc */
92-
public async close(timeout?: number | undefined): Promise<boolean> {
93+
// @ts-expect-error - PromiseLike is a subset of Promise
94+
public async close(timeout?: number | undefined): PromiseLike<boolean> {
9395
if (this._clientReportInterval) {
9496
clearInterval(this._clientReportInterval);
9597
}

0 commit comments

Comments
 (0)