diff --git a/dev-packages/browser-integration-tests/utils/generatePage.ts b/dev-packages/browser-integration-tests/utils/generatePage.ts index a74cd7dfe7bb..463bd9e26716 100644 --- a/dev-packages/browser-integration-tests/utils/generatePage.ts +++ b/dev-packages/browser-integration-tests/utils/generatePage.ts @@ -2,7 +2,7 @@ import { mkdirSync } from 'fs'; import HtmlWebpackPlugin from 'html-webpack-plugin'; import webpack from 'webpack'; import webpackConfig from '../webpack.config'; -import SentryScenarioGenerationPlugin from './generatePlugin'; +import SentryScenarioGenerationPlugin, { useLoader } from './generatePlugin'; export async function generatePage( initPath: string, @@ -30,6 +30,9 @@ export async function generatePage( filename: outPageName, template: templatePath, inject: 'body', + // Deferred scripts may run after the loader has swapped in the CDN bundle but before it calls + // `init()`, so their SDK calls would be dropped. Blocking scripts always hit the loader stub. + scriptLoading: useLoader ? 'blocking' : 'defer', }), ], }), diff --git a/dev-packages/browser-integration-tests/utils/generatePlugin.ts b/dev-packages/browser-integration-tests/utils/generatePlugin.ts index b7a8b803a243..3dfdbb25288c 100644 --- a/dev-packages/browser-integration-tests/utils/generatePlugin.ts +++ b/dev-packages/browser-integration-tests/utils/generatePlugin.ts @@ -19,7 +19,7 @@ const useCompiledModule = bundleKey === 'esm' || bundleKey === 'cjs'; // Bundles need to be injected into HTML before Sentry initialization. const useBundleOrLoader = bundleKey && !useCompiledModule; -const useLoader = bundleKey.startsWith('loader'); +export const useLoader = bundleKey.startsWith('loader'); // These are imports that, when using CDN bundles, are not included in the main CDN bundle. // In this case, if we encounter this import, we want to add this CDN bundle file instead