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
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { browserProfilingIntegration } from '@sentry/browser';

window.Sentry = Sentry;

Sentry.init({
const client = Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
integrations: [browserProfilingIntegration()],
tracesSampleRate: 1,
profileSessionSampleRate: 1,
profileLifecycle: 'trace',
});

function largeSum(amount = 1000000) {
function largeSum(amount) {
let sum = 0;
for (let i = 0; i < amount; i++) {
sum += Math.sqrt(i) * Math.sin(i);
Expand All @@ -28,7 +28,8 @@ function fibonacci(n) {
let firstSpan;

Sentry.startSpanManual({ name: 'root-largeSum-1', parentSpan: null, forceTransaction: true }, span => {
largeSum();
// Enough iterations that largeSum stays on-stack across several profiler ticks (10ms interval); otherwise sampling can miss it entirely.
largeSum(2_500_000);
firstSpan = span;
});

Expand All @@ -39,14 +40,13 @@ await Sentry.startSpanManual({ name: 'root-fibonacci-2', parentSpan: null, force
console.log('child span');
});

// Timeout to prevent flaky tests. Integration samples every 20ms, if function is too fast it might not get sampled
await new Promise(resolve => setTimeout(resolve, 21));
// Profiler uses a 10ms sample interval — wait long enough for multiple ticks
await new Promise(resolve => setTimeout(resolve, 40));
span.end();
});

await new Promise(r => setTimeout(r, 21));
await new Promise(r => setTimeout(r, 40));

firstSpan.end();

const client = Sentry.getClient();
await client?.flush(5000);
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ sentryTest(
const profileChunkEnvelopes = await getMultipleSentryEnvelopeRequests<ProfileChunkEnvelope>(
page,
1,
{ url, envelopeType: 'profile_chunk', timeout: 5000 },
{ url, envelopeType: 'profile_chunk', timeout: 15_000 },
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreliable envelope helper used in flakiness fix

Low Severity

The PR aims to reduce flakiness but still relies on getMultipleSentryEnvelopeRequests, which the project rules explicitly mark as unreliable. The rules recommend using helpers like waitForTransaction, waitForError, waitForSpans, etc. instead. While the timeout increase from 5s to 15s may help, using a more reliable waiting mechanism would better address the root cause of the flakiness. Flagged because the project rules file requires flagging usage of getMultipleEnvelope* helpers.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 29282fd. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine here.

properFullEnvelopeRequestParser,
);

Expand Down
Loading