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
11 changes: 10 additions & 1 deletion src/browser/cdp/selectivity/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,16 @@ export const startSelectivity = async (browser: ExistingBrowser): Promise<StopSe
const cssSelectivity = new CSSSelectivity(browser.cdp, sessionId, sourceRoot);
const jsSelectivity = new JSSelectivity(browser.cdp, sessionId, sourceRoot);

await Promise.all([cssSelectivity.start(), jsSelectivity.start()]);
await Promise.allSettled([cssSelectivity.start(), jsSelectivity.start()]).then(async ([css, js]) => {
if (css.status === "rejected" || js.status === "rejected") {
await Promise.all([cssSelectivity.stop(true), jsSelectivity.stop(true)]);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cant throw when drop=true is passed


const originalError =
css.status === "rejected" ? css.reason : js.status === "rejected" ? js.reason : "unknown reason";
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"unknown reason" path is impossible, but typescript wants to be 100% sure


throw new Error(`Selectivity: Couldn't start selectivity: ${originalError}`);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we'll lose stack and cause of original error if they are present. I'd use throw new Error('...message', {cause: originalError}) to preserve all originalError data.

Copy link
Copy Markdown
Member Author

@KuznetsovRoman KuznetsovRoman Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix it in next PR in multiple places to avoid rebases

}
});

/** @param drop only performs cleanup without writing anything. Should be "true" if test is failed */
return async function stopSelectivity(test: Test, drop: boolean): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions src/browser/cdp/selectivity/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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}")`);
Expand Down
Loading