diff --git a/packages/core/src/client.ts b/packages/core/src/client.ts index 88fab9107874..75a0d5ed49d2 100644 --- a/packages/core/src/client.ts +++ b/packages/core/src/client.ts @@ -415,10 +415,9 @@ export abstract class Client { env = addItemToEnvelope(env, createAttachmentEnvelopeItem(attachment)); } - const promise = this.sendEnvelope(env); - if (promise) { - promise.then(sendResponse => this.emit('afterSendEvent', event, sendResponse), null); - } + // sendEnvelope should not throw + // eslint-disable-next-line @typescript-eslint/no-floating-promises + this.sendEnvelope(env).then(sendResponse => this.emit('afterSendEvent', event, sendResponse)); } /** @@ -879,12 +878,11 @@ export abstract class Client { if (this._isEnabled() && this._transport) { return this._transport.send(envelope).then(null, reason => { DEBUG_BUILD && debug.error('Error while sending envelope:', reason); - return reason; + return {}; }); } DEBUG_BUILD && debug.error('Transport disabled'); - return resolvedSyncPromise({}); } diff --git a/packages/core/test/lib/client.test.ts b/packages/core/test/lib/client.test.ts index cb44d7212945..b7767a7e6c58 100644 --- a/packages/core/test/lib/client.test.ts +++ b/packages/core/test/lib/client.test.ts @@ -2268,7 +2268,7 @@ describe('Client', () => { expect(mockSend).toBeCalledTimes(1); expect(callback).toBeCalledTimes(1); - expect(callback).toBeCalledWith(errorEvent, 'send error'); + expect(callback).toBeCalledWith(errorEvent, {}); }); it('passes the response to the hook', async () => { diff --git a/packages/replay-internal/src/coreHandlers/handleAfterSendEvent.ts b/packages/replay-internal/src/coreHandlers/handleAfterSendEvent.ts index 827fc6f5b99b..4df1b62532ac 100644 --- a/packages/replay-internal/src/coreHandlers/handleAfterSendEvent.ts +++ b/packages/replay-internal/src/coreHandlers/handleAfterSendEvent.ts @@ -14,11 +14,10 @@ export function handleAfterSendEvent(replay: ReplayContainer): AfterSendEventCal return; } - const statusCode = sendResponse?.statusCode; + const statusCode = sendResponse.statusCode; // We only want to do stuff on successful error sending, otherwise you get error replays without errors attached - // If not using the base transport, we allow `undefined` response (as a custom transport may not implement this correctly yet) - // If we do use the base transport, we skip if we encountered an non-OK status code + // We skip if we encountered an non-OK status code if (!statusCode || statusCode < 200 || statusCode >= 300) { return; }