Skip to content

Commit

Permalink
fix(core): Fix racecondition that modifies in-flight sessions (#8203)
Browse files Browse the repository at this point in the history
  • Loading branch information
lforst committed May 24, 2023
1 parent 55ff2a1 commit df59f66
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/envelope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function createSessionEnvelope(
};

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

return createEnvelope<SessionEnvelope>(envelopeHeaders, [envelopeItem]);
}
Expand Down
5 changes: 3 additions & 2 deletions packages/types/src/envelope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { DsnComponents } from './dsn';
import type { Event } from './event';
import type { ReplayEvent, ReplayRecordingData } from './replay';
import type { SdkInfo } from './sdkinfo';
import type { Session, SessionAggregates } from './session';
import type { SerializedSession, Session, SessionAggregates } from './session';
import type { Transaction } from './transaction';
import type { UserFeedback } from './user';

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

0 comments on commit df59f66

Please sign in to comment.