Skip to content

Commit 8f9b9df

Browse files
authored
test(node): Unflake feature flag test (#16636)
This seems flaky (e.g. https://github.com/getsentry/sentry-javascript/actions/runs/15727905218/job/44322221132?pr=16633), likely because they may be flushed at the same time I suppose!
1 parent 784869d commit 8f9b9df

File tree

1 file changed

+19
-11
lines changed
  • dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onError/withScope

1 file changed

+19
-11
lines changed
Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
1-
import type { Scope } from '@sentry/node';
21
import * as Sentry from '@sentry/node';
32
import { loggingTransport } from '@sentry-internal/node-integration-tests';
43

4+
const flagsIntegration = Sentry.featureFlagsIntegration();
5+
56
Sentry.init({
67
dsn: 'https://[email protected]/1337',
78
sampleRate: 1.0,
89
transport: loggingTransport,
9-
integrations: [Sentry.featureFlagsIntegration()],
10+
integrations: [flagsIntegration],
1011
});
1112

12-
const flagsIntegration = Sentry.getClient()?.getIntegrationByName<Sentry.FeatureFlagsIntegration>('FeatureFlags');
13-
flagsIntegration?.addFeatureFlag('shared', true);
13+
async function run(): Promise<void> {
14+
flagsIntegration.addFeatureFlag('shared', true);
1415

15-
Sentry.withScope((_scope: Scope) => {
16-
flagsIntegration?.addFeatureFlag('forked', true);
17-
flagsIntegration?.addFeatureFlag('shared', false);
18-
Sentry.captureException(new Error('Error in forked scope'));
19-
});
16+
Sentry.withScope(() => {
17+
flagsIntegration.addFeatureFlag('forked', true);
18+
flagsIntegration.addFeatureFlag('shared', false);
19+
Sentry.captureException(new Error('Error in forked scope'));
20+
});
21+
22+
await Sentry.flush();
23+
24+
flagsIntegration.addFeatureFlag('main', true);
25+
26+
throw new Error('Error in main scope');
27+
}
2028

21-
flagsIntegration?.addFeatureFlag('main', true);
22-
throw new Error('Error in main scope');
29+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
30+
run();

0 commit comments

Comments
 (0)