AppiumTestDistribution / appium-device-farm

This is an Appium 2.0 plugin designed to manage and create driver sessions on available devices.
https://devicefarm.org
Other
321 stars 99 forks source link

Appium Server stops after the device-farm plugin executes a method isValidStorageFileContent() #771

Open dorogova-snezhana opened 1 year ago

dorogova-snezhana commented 1 year ago

Describe the bug

  1. Start Appium with device-farm plugin
  2. Create a new driver session
  3. Execute test steps and quit the driver.
  4. After executing a method DELETE /wd/hub/session/b5e5431e-b741-4cb2-9080-6e6c08239cce the device-farm plugin executes a method isValidStorageFileContent() with failure and Appium Server stops.
2023-08-20 14:58:14:677 - uncaughtException: [node-persist][readFile] /Users/sydorogova/.cache/appium-device-farm/storage/c9f82560afc787af5f0673262f55e4a2 does not look like a valid storage file!
Error: [node-persist][readFile] /Users/sydorogova/.cache/appium-device-farm/storage/c9f82560afc787af5f0673262f55e4a2 does not look like a valid storage file!
    at /Users/sydorogova/.appium/node_modules/appium-device-farm/node_modules/node-persist/src/local-storage.js:316:89
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3)

Link to Appium logs

GIST

Environment

  1. Appium 2.1.0
  2. Driver uiautomator2@2.29.4
  3. Plugin device-farm@8.2.2
  4. Node.js v18.16.0
  5. Npm 9.5.1
  6. Emulator command: ${ANDROID_HOME}/emulator/emulator -avd Pixel7Pro_API33_13.0 -no-boot-anim -no-audio -netdelay none -netspeed full
deepakarorawins commented 1 year ago

For me it worked by setting environment variable as mentioned in trouble shooting document: https://appium-device-farm-eight.vercel.app/troubleshooting/

export GO_IOS="/opt/homebrew/lib/node_modules/go-ios/dist/go-ios-darwin-amd64_darwin_amd64/ios"

export PATH=$JAVA_HOME/bin:$GROOVY_HOME/bin:$GO_IOS:$PATH

saikrishna321 commented 1 year ago

@dorogova-snezhana Will fix this problem. In the mean time as a workaround can you delete the file manually /Users/sydorogova/.cache/appium-device-farm/storage/c9f82560afc787af5f0673262f55e4a2

saikrishna321 commented 1 year ago

@Dileep17

dorogova-snezhana commented 1 year ago

@saikrishna321 I've removed all files from directory /Users/sydorogova/.cache/appium-device-farm/storage and run tests. The Appium server is alive after the quit method execution. Tested on iOS and Android virtual devices.

saikrishna321 commented 1 year ago

This is expected driver.quit() will only end the session and not stop the server

dorogova-snezhana commented 1 year ago

It is perfect to stop a session only. The main goal is to start the Appium server and run tests in parallel on multiple virtual devices. After each test we stop session and create a new one to reinstall the app.

saikrishna321 commented 1 year ago

Yes this is a good approach.

luprochazka-cen63872 commented 8 months ago

@saikrishna321 Do you plan to fix this bug? I see the same behavior.

saikrishna321 commented 8 months ago

@luprochazka-cen63872 Can you share full logs please when this error occurs?

afathonih commented 3 months ago

This bug started biting me again recently. I think we can drop localStorage(since it's actually never used) and eventually also remove nodepersist from the equation. Itried it in my PR last year. It was working OK.I used the branch for months.

luprochazka-cen63872 commented 3 months ago

@luprochazka-cen63872 Can you share full logs please when this error occurs?

It is not necessary, in latest version it works without this problem. Thank you.

saikrishna321 commented 3 months ago

@afathonih We have plans to remove this localStorage. Will do it soon.