Skip to content

Commit df59f66

Browse files
authored
fix(core): Fix racecondition that modifies in-flight sessions (#8203)
1 parent 55ff2a1 commit df59f66

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/core/src/envelope.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function createSessionEnvelope(
4848
};
4949

5050
const envelopeItem: SessionItem =
51-
'aggregates' in session ? [{ type: 'sessions' }, session] : [{ type: 'session' }, session];
51+
'aggregates' in session ? [{ type: 'sessions' }, session] : [{ type: 'session' }, session.toJSON()];
5252

5353
return createEnvelope<SessionEnvelope>(envelopeHeaders, [envelopeItem]);
5454
}

packages/types/src/envelope.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { DsnComponents } from './dsn';
44
import type { Event } from './event';
55
import type { ReplayEvent, ReplayRecordingData } from './replay';
66
import type { SdkInfo } from './sdkinfo';
7-
import type { Session, SessionAggregates } from './session';
7+
import type { SerializedSession, Session, SessionAggregates } from './session';
88
import type { Transaction } from './transaction';
99
import type { UserFeedback } from './user';
1010

@@ -76,7 +76,8 @@ export type EventItem = BaseEnvelopeItem<EventItemHeaders, Event>;
7676
export type AttachmentItem = BaseEnvelopeItem<AttachmentItemHeaders, string | Uint8Array>;
7777
export type UserFeedbackItem = BaseEnvelopeItem<UserFeedbackItemHeaders, UserFeedback>;
7878
export type SessionItem =
79-
| BaseEnvelopeItem<SessionItemHeaders, Session>
79+
// TODO(v8): Only allow serialized session here (as opposed to Session or SerializedSesison)
80+
| BaseEnvelopeItem<SessionItemHeaders, Session | SerializedSession>
8081
| BaseEnvelopeItem<SessionAggregatesItemHeaders, SessionAggregates>;
8182
export type ClientReportItem = BaseEnvelopeItem<ClientReportItemHeaders, ClientReport>;
8283
export type CheckInItem = BaseEnvelopeItem<CheckInItemHeaders, SerializedCheckIn>;

0 commit comments

Comments
 (0)