Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions packages/core/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,9 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
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));
}

/**
Expand Down Expand Up @@ -879,12 +878,11 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
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({});
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/lib/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading