Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize ADB commands timeout #259

Open
gaetanlgce opened this issue Sep 26, 2022 · 9 comments · May be fixed by #392 or #393
Open

Customize ADB commands timeout #259

gaetanlgce opened this issue Sep 26, 2022 · 9 comments · May be fixed by #392 or #393

Comments

@gaetanlgce
Copy link

Hi,

On old devices, ADB invocation can be quite long to be executed, more than 5 seconds.
It could be useful to allow overriding the value of 5 seconds. (cf issue #5).

Currently, I edit the dist version of the file (https://github.com/ionic-team/native-run/blob/develop/src/android/utils/adb.ts#L469) in my node_modules to force another value of timeout.

Is there a proper way to pass a param for that. I don't use native-run directly but I use the ionic/cordova stack that use native-run. Maybe an environment variable ?

@me-to-you93
Copy link

Same problem here, would be interested by this option !

@markemer
Copy link
Member

markemer commented Mar 6, 2023

I'll look into this - seems like we could do this in a non-breaking way.

I'm not sure when I can get to it - but I'll put it on my radar.

If you are interested in helping I'd be happy to review any PR you'd post.

@Dexus
Copy link

Dexus commented Sep 27, 2024

To bad that this never found its way to the code...

@piotr-cz
Copy link

The timeout argument would have to be read here:

export async function run(args: readonly string[]): Promise<void> {

and passed all the way to here:

export async function execAdb(sdk: SDK, args: string[], options: ExecADBOptions = {}): Promise<string> {

@piotr-cz
Copy link

For me, it looks like that:

  • the startActivity function executes ADB command which longer than 5s
  • the execAdb function times out
  • retrying fails, as the first ADB command is still executing
  • app is deployed and started on device
  • native-run exits with an error
npx capacitor run --live-reload --port 8100
...
√ Running Gradle build in 4.87s
× Deploying app-debug.apk to Pixel_9_API_35 - failed!
[error] Selected hardware device emulator-5554
        Installing xxx\android\app\build\outputs\apk\debug\app-debug.apk...
        Starting application activity xxx/xxx.MainActivity...
        ADBs is unresponsive after 5000ms, killing server and retrying...
        Error: Command failed: C:\Users\xxx\AppData\Local\Android\Sdk\platform-tools\adb -s emulator-5554 shell am
        start -W -n xxx/xxx.MainActivity
        adb.exe: device offline

        at ChildProcess.exithandler (node:child_process:422:12)
        at ChildProcess.emit (node:events:517:28)
        at maybeClose (node:internal/child_process:1098:16)
        at ChildProcess._handle.onexit (node:internal/child_process:303:5)

@piotr-cz
Copy link

piotr-cz commented Oct 25, 2024

I prepared PR #393 that increases timeout to 15_000 ms, because it works for my case.

@gaetanlgce @me-to-you93 @Dexus please let me know in above PR which timeout duration works for you

@Dexus
Copy link

Dexus commented Oct 25, 2024

I have patched it my own thanks to patch-package so I was able to set it to 30_000 that was working for me

@thoro23
Copy link

thoro23 commented Nov 12, 2024

We have the same problem, the starting of the activity takes longer than 5s when deploying to an emulator. When deploying to a device it takes less than 5s and works fine.

For now we patch it with patch-package like @Dexus suggested but a proper fix would be preferable.

@xEverth
Copy link

xEverth commented Dec 25, 2024

Device offline and device still authorizing errors from ADB should be caught and retried on by native-run - increasing the timeout via environment variable or patch to startActivity just moves the issue slightly further without addressing it.
Also native-run seems a little too trigger-happy with adb kill-server currently

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants