Skip to content

Commit

Permalink
testing: fix promise rejection error (#8283)
Browse files Browse the repository at this point in the history
<!--
Thank you for your contribution.

Before making a PR, please read our contributing guidelines at

https://github.com/DevExpress/testcafe/blob/master/CONTRIBUTING.md#code-contribution

We recommend creating a *draft* PR, so that you can mark it as 'ready
for review' when you are done.
-->

## 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 #8258

## Pre-Merge TODO
- [ ] Write tests for your proposed changes
- [ ] Make sure that existing tests do not fail

---------

Co-authored-by: Bayheck <[email protected]>
  • Loading branch information
Bayheck and Bayheck authored Sep 28, 2024
1 parent 4c9f03b commit 0514273
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/native-automation/request-pipeline/safe-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>, handleErrorFn: (err: any) => void): Promise<void> {
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);
Expand Down

0 comments on commit 0514273

Please sign in to comment.