From 05142735e1646046aaf5bc87b2aed67cd4dee2d1 Mon Sep 17 00:00:00 2001 From: Adil Rakhaliyev <67043367+Bayheck@users.noreply.github.com> Date: Sat, 28 Sep 2024 20:06:02 +0500 Subject: [PATCH] testing: fix promise rejection error (#8283) ## Purpose _Describe the problem you want to address or the feature you want to implement._ ## Approach _Describe how your changes address the issue or implement the desired functionality in as much detail as possible._ ## References closes https://github.com/DevExpress/testcafe/issues/8258 ## Pre-Merge TODO - [ ] Write tests for your proposed changes - [ ] Make sure that existing tests do not fail --------- Co-authored-by: Bayheck --- src/native-automation/request-pipeline/safe-api.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/native-automation/request-pipeline/safe-api.ts b/src/native-automation/request-pipeline/safe-api.ts index 86706e69a9c..c29d0e2f45a 100644 --- a/src/native-automation/request-pipeline/safe-api.ts +++ b/src/native-automation/request-pipeline/safe-api.ts @@ -16,13 +16,15 @@ const IGNORED_ERROR_CODES = { // The "Session not found" error can occur in iframes for unclear reasons. SESSION_WITH_GIVEN_ID_NOT_FOUND: -32001, }; +//The "WebSocket connection closed" error occurs on closeWindow in multiple windows mode +const IGNORED_ERROR_MESSAGES = ['WebSocket connection closed']; export async function connectionResetGuard (handleRequestFn: () => Promise, handleErrorFn: (err: any) => void): Promise { try { await handleRequestFn(); } catch (err: any) { - if (Object.values(IGNORED_ERROR_CODES).includes(err?.response?.code)) + if (Object.values(IGNORED_ERROR_CODES).includes(err?.response?.code) || IGNORED_ERROR_MESSAGES.includes(err.message)) return; handleErrorFn(err);