ERROR [BROWSERSTACK_SO_TIMEOUT] Session errored because an Appium command failed to respond and timed out

Hello,

I am facing this problem when I run 3 scenarios in one feature using appium, wdio in browserstack.
I am having this error in browserstack ERROR [BROWSERSTACK_SO_TIMEOUT] Session errored because an Appium command failed to respond and timed out

And in my console I have this one:

Error: Session not started or terminated
    at Object.getErrorFromResponseBody (/Users/fatma/Desktop/e2e-tests/e2e-tests/node_modules/webdriver/build/utils.js:189:12)
    at WebDriverRequest._request (/Users/fatma/Desktop/e2e-tests/e2e-tests/node_modules/webdriver/build/request.js:168:31)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at Element.wrapCommandFn (/Users/fatma/Desktop/e2e-tests/e2e-tests/node_modules/@wdio/utils/build/shim.js:78:29)
    at Element.wrapCommandFn (/Users/fatma/Desktop/e2e-tests/e2e-tests/node_modules/@wdio/utils/build/shim.js:78:29)
    at Element.elementErrorHandlerCallbackFn (/Users/fatma/Desktop/e2e-tests/e2e-tests/node_modules/webdriverio/build/middlewares.js:23:32)
    at Element.wrapCommandFn (/Users/fatma/Desktop/e2e-tests/e2e-tests/node_modules/@wdio/utils/build/shim.js:78:29)
    at Element.wrapCommandFn (/Users/fatma/Desktop/e2e-tests/e2e-tests/node_modules/@wdio/utils/build/shim.js:78:29)
    at Element.elementErrorHandlerCallbackFn (/Users/fatma/Desktop/e2e-tests/e2e-tests/node_modules/webdriverio/build/middlewares.js:23:32)
    at Element.wrapCommandFn (/Users/fatma/Desktop/e2e-tests/e2e-tests/node_modules/@wdio/utils/build/shim.js:78:29)
    at Object.iTapButton (/Users/fatma/Desktop/e2e-tests/e2e-tests/src/action_words.js:23:13)
    at World.<anonymous> (/Users/fatma/Desktop/e2e-tests/e2e-tests/src/step_definitions.js:25:5)
    at World.executeAsync (/Users/fatma/Desktop/e2e-tests/e2e-tests/node_modules/@wdio/utils/build/shim.js:136:16)
    at World.testFrameworkFnWrapper (/Users/fatma/Desktop/e2e-tests/e2e-tests/node_modules/@wdio/utils/build/test-framework/testFnWrapper.js:52:18)

I am really lost. When I skip one scenario the rest is running well.
Here are the details:

Feature file

@ios-only
    Scenario: scenario 1
        When I clear the text and write "[email protected]" in the "Email Authentication Field" field
        And I tap enter on keyboard
        And I clear the text and write "pwd" in the "Password Authentication Field" field
        And I tap the "Sign In Submit Button" button
        And I tap the "Skip Link" button
        And I tap the "push" button
        And I should see the "test cell 1" cell
        #And I should see the "test cell 2" cell
    


    @ios-only
    Scenario: scenario 2
        When I clear the text and write "[email protected]"" in the "Email Authentication Field" field
        And I tap enter on keyboard
        And I clear the text and write "pwd" in the "Password Authentication Field" field
        And I tap the "Sign In Submit Button" button
        And I tap the "Skip Link" button
        And I should see the "test cell 1" cell
        And I should see the "test cell 2" cell



    @ios-only
    Scenario: scenario 3
        When I clear the text and write "[email protected]" in the "Email Authentication Field" field
        And I tap enter on keyboard
        And I clear the text and write "pwd" in the "Password Authentication Field" field
        And I tap the "Sign In Submit Button" button
        And I tap the "Skip Link" button
        And I should see the "test cell 3" cell

My functions:

iShouldSeeTheCell: async function (text) {
        let selector = Screen.cellSelect(text);
        let button = await $(selector);
        
        if (!button.isExisting()) {
            driver.execute('mobile: scroll', { direction: 'up' });
        }
        await button.waitForExist({ timeout: 90000 });
        expect(await button.isExisting()).to.be.equal(true);
    },  
// to check if the cell exists for the step "I should see the "test cell" cell 

 cellSelect(name) {
        return `-ios predicate string:type=='XCUIElementTypeCell' AND name=='${name}'`;
    }

// tap button
iTapButton: async function (btn) {
        let selector = Screen.getSelector(btn);
        let button = await $(selector);
        await driver.pause(5000);

        try {
            if (!button.isExisting()) {
                 driver.execute('mobile: scroll', { direction: 'down' });

                await button.waitForExist({ timeout: 200000 });
            }
            await button.waitForExist({ timeout: 200000 });
            await button.touchAction('tap');
        }
        catch (error) {
            throw error;
        }
    },

My capabilities:

capabilities: [{
        project: 'Mobile automation',
        build: 'Webdriverio V7',
        name: 'com.ios',
        device: 'iPhone XS',
        os_version: '14.0',
        app: 'Test_iOS_v3.4',
        language: 'fr',
        locale: 'fr_FR',
        country: 'FR',
        timezone: 'Europe/Paris',
        'browserstack.local': true,
        'browserstack.debug': true,
        'browserstack.networkLogs': false,
    }],

    logLevel: 'error',
    coloredLogs: true,
    screenshotPath: './errorShots/',
    baseUrl: '',
    waitforTimeout: 30000,
    connectionRetryTimeout: 90000,
    connectionRetryCount: 3,
    maxInstances: 2,
    specFileRetries: 0,
    specFileRetriesDelay: 5,
    specFileRetriesDeferred: true,

    reporters: [
        'dot',
        ['allure', {
            outputDir: 'reports/allure/',
            disableWebdriverStepsReporting: true,
            disableWebdriverScreenshotsReporting: false,
            useCucumberStepReporter: false
        }],
        ['cucumberjs-json', {
            jsonFolder: 'reports/cucumber/',
            language: 'en',
        }]
    ],

    framework: 'cucumber',
    cucumberOpts: {
        require: ['./src/step_definitions.js'],
        tagExpression: '(@automated) and (@ios or @ios-only) and (not @skip and not @need-work and not @android-only)',
        backtrace: true,
        compiler: ['@babel/register'],
        failFast: false,
        timeout: 5 * 60 * 1000,
        ignoreUndefinedDefinitions: false,
        tags: [],
        colors: true,
        deviceName: 'iOS'
    },

Package file:

  "name": "e2e-tests",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "test": "npm run clean ; npm run android-bs-test",
    "android-bs-test": "npx wdio run ./config/android/wdio.bs.config.js",
    "android-bs-es-test": "npx wdio run ./config/android/wdio.bs.es.config.js",
    "android-bs-it-test": "npx wdio run ./config/android/wdio.bs.it.config.js",
    "android-bs-pt-test": "npx wdio run ./config/android/wdio.bs.pt.config.js",
    "android-bs-befr-test": "npx wdio run ./config/android/wdio.bs.befr.config.js",
    "android-bs-benl-test": "npx wdio run ./config/android/wdio.bs.benl.config.js",
    "ios-bs-test": "npx wdio run ./config/ios/wdio.bs.config.js",
    "ios-bs-es-test": "npx wdio run ./config/ios/wdio.bs.es.config.js",
    "ios-bs-it-test": "npx wdio run ./config/ios/wdio.bs.it.config.js",
    "ios-bs-pt-test": "npx wdio run ./config/ios/wdio.bs.pt.config.js",
    "ios-bs-befr-test": "npx wdio run ./config/ios/wdio.bs.befr.config.js",
    "ios-bs-benl-test": "npx wdio run ./config/ios/wdio.bs.benl.config.js",
    "clean": "rm -Rf ./reports/*",
    "report-allure": "npx allure generate ./reports/allure/ --clean",
    "report-hiptest": "echo \"Error: no test specified\" && exit 1",
    "view-allure": "docker-compose down && docker-compose up -d",
    "launch-stats":"bash ./config/stats.sh"

  },
  "dependencies": {
    "@babel/core": "^7.14.3",
    "@babel/preset-env": "^7.14.4",
    "@babel/register": "^7.13.16",
    "@cucumber/cucumber": "^7.2.1",
    "@wdio/allure-reporter": "^7.7.3",
    "@wdio/cli": "^7.7.3",
    "@wdio/cucumber-framework": "^7.7.3",
    "@wdio/dot-reporter": "^7.7.3",
    "@wdio/local-runner": "^7.7.3",
    "@wdio/mocha-framework": "^7.7.3",
    "allure-commandline": "^2.13.8",
    "browserstack-local": "^1.4.8",
    "chai": "^4.3.4",
    "chai-as-promised": "^7.1.1",
    "cucumberjs-allure-reporter": "^1.0.3",
    "maven": "^5.0.0",
    "wdio-cucumberjs-json-reporter": "^3.0.0"
  }
}

Is there someone here facing the same issue please?
Thank you

Does the test run locally? If so this is probably a BrowserStack issue. Here is their support page, I would encourage you to click, ‘Contact Support’ and let them know the issue. If you are paying for this service then you are entitled to support:

https://www.browserstack.com/support