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
8 changes: 7 additions & 1 deletion packages/core/src/tracing/idleSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import { timestampInSeconds } from '../utils/time';
import { freezeDscOnSpan, getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';
import { SentryNonRecordingSpan } from './sentryNonRecordingSpan';
import { SentrySpan } from './sentrySpan';
import { SPAN_STATUS_ERROR } from './spanstatus';
import { startInactiveSpan } from './trace';

Expand Down Expand Up @@ -326,7 +327,12 @@ export function startIdleSpan(startSpanOptions: StartSpanOptions, options: Parti
// or if this is the idle span itself being started,
// or if the started span has already been closed,
// we don't care about it for activity
if (_finished || startedSpan === span || !!spanToJSON(startedSpan).timestamp) {
if (
_finished ||
startedSpan === span ||
!!spanToJSON(startedSpan).timestamp ||
(startedSpan instanceof SentrySpan && startedSpan.isStandaloneSpan())
) {
return;
}

Expand Down
22 changes: 22 additions & 0 deletions packages/core/test/lib/tracing/idleSpan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,28 @@ describe('startIdleSpan', () => {
expect(spanToJSON(idleSpan).status).not.toEqual('deadline_exceeded');
expect(spanToJSON(idleSpan).timestamp).toBeDefined();
});

it("doesn't reset the timeout for standalone spans", () => {
const idleSpan = startIdleSpan({ name: 'idle span' }, { finalTimeout: 99_999 });
expect(idleSpan).toBeDefined();

// Start any span to cancel idle timeout
startInactiveSpan({ name: 'span' });

// Wait some time
vi.advanceTimersByTime(TRACING_DEFAULTS.childSpanTimeout - 1000);
expect(spanToJSON(idleSpan).status).not.toEqual('deadline_exceeded');
expect(spanToJSON(idleSpan).timestamp).toBeUndefined();

// new standalone span should not reset the timeout
const standaloneSpan = startInactiveSpan({ name: 'standalone span', experimental: { standalone: true } });
expect(standaloneSpan).toBeDefined();

// Wait for timeout to exceed
vi.advanceTimersByTime(1001);
expect(spanToJSON(idleSpan).status).not.toEqual('deadline_exceeded');
expect(spanToJSON(idleSpan).timestamp).toBeDefined();
});
});

describe('disableAutoFinish', () => {
Expand Down
Loading