From ded3cfcfb423a9b4a2a09ee574888ab85322d896 Mon Sep 17 00:00:00 2001 From: Roman Kuznetsov Date: Thu, 5 Feb 2026 10:31:55 +0300 Subject: [PATCH] fix: handle init selectivity error --- src/browser/cdp/selectivity/index.ts | 11 ++++++++++- src/browser/cdp/selectivity/utils.ts | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/browser/cdp/selectivity/index.ts b/src/browser/cdp/selectivity/index.ts index 1807c4e71..e7847465e 100644 --- a/src/browser/cdp/selectivity/index.ts +++ b/src/browser/cdp/selectivity/index.ts @@ -81,7 +81,16 @@ export const startSelectivity = async (browser: ExistingBrowser): Promise { + if (css.status === "rejected" || js.status === "rejected") { + await Promise.all([cssSelectivity.stop(true), jsSelectivity.stop(true)]); + + const originalError = + css.status === "rejected" ? css.reason : js.status === "rejected" ? js.reason : "unknown reason"; + + throw new Error(`Selectivity: Couldn't start selectivity: ${originalError}`); + } + }); /** @param drop only performs cleanup without writing anything. Should be "true" if test is failed */ return async function stopSelectivity(test: Test, drop: boolean): Promise { diff --git a/src/browser/cdp/selectivity/utils.ts b/src/browser/cdp/selectivity/utils.ts index c3ddee41a..dd1061c90 100644 --- a/src/browser/cdp/selectivity/utils.ts +++ b/src/browser/cdp/selectivity/utils.ts @@ -144,7 +144,7 @@ const getProtocol = (fileUrlLikePath: string): string | null => { } }; -const ensurePosixRelativeDependencyPathExists = memoize((posixRelativePath: string): void => { +const ensurePosixRelativeDependencyPathExists = (posixRelativePath: string): void => { const relativePath = posixRelativePath.replaceAll(path.posix.sep, path.sep); if (fs.existsSync(relativePath)) { @@ -158,7 +158,7 @@ const ensurePosixRelativeDependencyPathExists = memoize((posixRelativePath: stri "Configuring 'sourceRoot' in Testplane selectivity config also might help", ].join("\n"), ); -}); +}; const warnUnsupportedProtocol = memoize((protocol: string, dependency: string): void => { logger.warn(`Selectivity: Ignoring dependencies of unsupported protocol "${protocol}" (example: "${dependency}")`);