From 646417ac2970d86609977b8775d36f5a9e836fdf Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 18 Jun 2025 11:22:33 +0200 Subject: [PATCH 1/3] test(node): Unflake feature flag test --- .../onError/withScope/scenario.ts | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onError/withScope/scenario.ts b/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onError/withScope/scenario.ts index b6537011a87f..fbbd41ab7f51 100644 --- a/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onError/withScope/scenario.ts +++ b/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onError/withScope/scenario.ts @@ -1,22 +1,26 @@ -import type { Scope } from '@sentry/node'; import * as Sentry from '@sentry/node'; import { loggingTransport } from '@sentry-internal/node-integration-tests'; +const flagsIntegration = Sentry.featureFlagsIntegration(); + Sentry.init({ dsn: 'https://public@dsn.ingest.sentry.io/1337', sampleRate: 1.0, transport: loggingTransport, - integrations: [Sentry.featureFlagsIntegration()], + integrations: [flagsIntegration], }); -const flagsIntegration = Sentry.getClient()?.getIntegrationByName('FeatureFlags'); -flagsIntegration?.addFeatureFlag('shared', true); +flagsIntegration.addFeatureFlag('shared', true); -Sentry.withScope((_scope: Scope) => { - flagsIntegration?.addFeatureFlag('forked', true); - flagsIntegration?.addFeatureFlag('shared', false); +Sentry.withScope(() => { + flagsIntegration.addFeatureFlag('forked', true); + flagsIntegration.addFeatureFlag('shared', false); Sentry.captureException(new Error('Error in forked scope')); }); -flagsIntegration?.addFeatureFlag('main', true); -throw new Error('Error in main scope'); +flagsIntegration.addFeatureFlag('main', true); + +// To ensure order of sent events +setTimeout(() => { + throw new Error('Error in main scope'); +}, 1); From e879b402dd8f3f89dfabb93f35126cc2c7bc0ddf Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 18 Jun 2025 11:37:05 +0200 Subject: [PATCH 2/3] wait longer --- .../featureFlagsIntegration/onError/withScope/scenario.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onError/withScope/scenario.ts b/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onError/withScope/scenario.ts index fbbd41ab7f51..d4c1b97e7c75 100644 --- a/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onError/withScope/scenario.ts +++ b/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onError/withScope/scenario.ts @@ -23,4 +23,4 @@ flagsIntegration.addFeatureFlag('main', true); // To ensure order of sent events setTimeout(() => { throw new Error('Error in main scope'); -}, 1); +}, 100); From 2ce27c9b5022db31332d2bbb43680fac812094b5 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 18 Jun 2025 11:39:58 +0200 Subject: [PATCH 3/3] better unflake --- .../onError/withScope/scenario.ts | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onError/withScope/scenario.ts b/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onError/withScope/scenario.ts index d4c1b97e7c75..4ba9d63b9733 100644 --- a/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onError/withScope/scenario.ts +++ b/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onError/withScope/scenario.ts @@ -10,17 +10,21 @@ Sentry.init({ integrations: [flagsIntegration], }); -flagsIntegration.addFeatureFlag('shared', true); +async function run(): Promise { + flagsIntegration.addFeatureFlag('shared', true); -Sentry.withScope(() => { - flagsIntegration.addFeatureFlag('forked', true); - flagsIntegration.addFeatureFlag('shared', false); - Sentry.captureException(new Error('Error in forked scope')); -}); + Sentry.withScope(() => { + flagsIntegration.addFeatureFlag('forked', true); + flagsIntegration.addFeatureFlag('shared', false); + Sentry.captureException(new Error('Error in forked scope')); + }); + + await Sentry.flush(); -flagsIntegration.addFeatureFlag('main', true); + flagsIntegration.addFeatureFlag('main', true); -// To ensure order of sent events -setTimeout(() => { throw new Error('Error in main scope'); -}, 100); +} + +// eslint-disable-next-line @typescript-eslint/no-floating-promises +run();