Android appium tests crash randomly

Good evening everyone! I ran into a problem that the tests I ran were successful every other time, although I didn’t change anything in the configuration or the tests themselves. The tests themselves fail due to very simple errors, such as “Cannot read properties of undefined (reading ‘click’)”. At the same time, on the next launch everything will be in order and it will work. I absolutely can’t understand what’s going on. Help me please!

Capabilities I have like this:

capabilities: {
     alwaysMatch: {
        platformName: 'Android',
        'appium:automationName': 'UiAutomator2',
        'appium:autoGrantPermissions': true,
        'appium:fullReset': true,
        'appium:newCommandTimeout': 40000,
        'appium:deviceName': 'emulator-5554',
        'appium:platformVersion': '13.0',
        'appium:app': 'appName'
      },
     firstMatch: [ {} ]
  },

The command in config.yml runs this:

  preproduction-e2e-android:
    working_directory: ~/android-deploy
    resource_class: xlarge
    docker:
      - image: cimg/android:2023.04.1-node
    environment:
      JVM_OPTS: -Xmx4096m
      JAVA_OPTS: '-Xms512m -Xmx2g'
      GRADLE_OPTS: '-Xmx3g -Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-Xmx2g -XX:+HeapDumpOnOutOfMemoryError"'
    steps:
      - setup-project:
          os_android: true
          env: 'preproduction'
      - setup-android
      - run:
          name: Fastlane
          command: bundle exec fastlane android build_preproduction_e2e_cloud
          environment:
            BUNDLE_PATH: vendor/bundle
      - yarn_install:
          cache: true
      - run:
          name: Temporary fix for npmrc auth issue
          command: npm config fix
      - run:
          name: Run the appium tests for Android
          command: TESTRAIL_USERNAME=$TESTRAIL_USERNAME TESTRAIL_API_TOKEN=$TESTRAIL_API_TOKEN CI=true yarn e2e:preprod:run:android:cloud