@wdio/appium-service 8.40.2 → 8.40.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,7 @@ export default class AppiumLauncher implements Services.ServiceInstance {
8
8
  private readonly _appiumCliArgs;
9
9
  private readonly _args;
10
10
  private _process?;
11
+ private _isShuttingDown;
11
12
  constructor(_options: AppiumServiceConfig, _capabilities: Capabilities.RemoteCapabilities, _config?: Options.Testrunner | undefined);
12
13
  private _getCommand;
13
14
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAIlE,OAAO,KAAK,EAAyB,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAY5E,MAAM,CAAC,OAAO,OAAO,cAAe,YAAW,QAAQ,CAAC,eAAe;IAO/D,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,OAAO,CAAC;IARpB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAe;IAC9C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAuB;IAC7C,OAAO,CAAC,QAAQ,CAAC,CAA+C;gBAGpD,QAAQ,EAAE,mBAAmB,EAC7B,aAAa,EAAE,YAAY,CAAC,kBAAkB,EAC9C,OAAO,CAAC,EAAE,OAAO,CAAC,UAAU,YAAA;YAS1B,WAAW;IAqBzB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAkDlB,SAAS;IAiCf,UAAU;IAMV,OAAO,CAAC,YAAY;YAoEN,kBAAkB;mBAeX,iBAAiB;CAezC"}
1
+ {"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAIlE,OAAO,KAAK,EAAyB,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAY5E,MAAM,CAAC,OAAO,OAAO,cAAe,YAAW,QAAQ,CAAC,eAAe;IAQ/D,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,OAAO,CAAC;IATpB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAe;IAC9C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAuB;IAC7C,OAAO,CAAC,QAAQ,CAAC,CAA+C;IAChE,OAAO,CAAC,eAAe,CAAiB;gBAG5B,QAAQ,EAAE,mBAAmB,EAC7B,aAAa,EAAE,YAAY,CAAC,kBAAkB,EAC9C,OAAO,CAAC,EAAE,OAAO,CAAC,UAAU,YAAA;YAS1B,WAAW;IAqBzB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAkDlB,SAAS;IAiCf,UAAU;IAiBV,OAAO,CAAC,YAAY;YAuEN,kBAAkB;mBAeX,iBAAiB;CAezC"}
package/build/launcher.js CHANGED
@@ -2,6 +2,7 @@ import fs from 'node:fs';
2
2
  import fsp from 'node:fs/promises';
3
3
  import url from 'node:url';
4
4
  import path from 'node:path';
5
+ import treeKill from 'tree-kill';
5
6
  import { spawn } from 'node:child_process';
6
7
  import logger from '@wdio/logger';
7
8
  import getPort from 'get-port';
@@ -27,6 +28,7 @@ export default class AppiumLauncher {
27
28
  _appiumCliArgs = [];
28
29
  _args;
29
30
  _process;
31
+ _isShuttingDown = false;
30
32
  constructor(_options, _capabilities, _config) {
31
33
  this._options = _options;
32
34
  this._capabilities = _capabilities;
@@ -119,9 +121,19 @@ export default class AppiumLauncher {
119
121
  }
120
122
  }
121
123
  onComplete() {
122
- if (this._process) {
123
- log.info(`Appium (pid: ${this._process.pid}) killed`);
124
- this._process.kill();
124
+ this._isShuttingDown = true;
125
+ // Kill appium and all process' spawned from it
126
+ if (this._process && this._process.pid) {
127
+ // Ensure all child processes are also killed
128
+ log.info('Killing entire Appium tree');
129
+ treeKill(this._process.pid, 'SIGTERM', (err) => {
130
+ if (err) {
131
+ log.warn('Failed to kill process:', err);
132
+ }
133
+ else {
134
+ log.info('Process and its children successfully terminated');
135
+ }
136
+ });
125
137
  }
126
138
  }
127
139
  _startAppium(command, args, timeout = APPIUM_START_TIMEOUT) {
@@ -173,6 +185,9 @@ export default class AppiumLauncher {
173
185
  rejectOnce(new Error(error));
174
186
  });
175
187
  process.once('exit', (exitCode) => {
188
+ if (this._isShuttingDown) {
189
+ return;
190
+ }
176
191
  let errorMessage = `Appium exited before timeout (exit code: ${exitCode})`;
177
192
  if (exitCode === 2) {
178
193
  errorMessage += '\n' + (error?.toString() || 'Check that you don\'t already have a running Appium service.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/appium-service",
3
- "version": "8.40.2",
3
+ "version": "8.40.4",
4
4
  "description": "A WebdriverIO service to start & stop Appium Server",
5
5
  "author": "Morten Bjerg Gregersen <morten@mogee.dk>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-appium-service",
@@ -33,17 +33,18 @@
33
33
  },
34
34
  "typeScriptVersion": "3.8.3",
35
35
  "dependencies": {
36
- "@wdio/config": "8.40.2",
36
+ "@wdio/config": "8.40.3",
37
37
  "@wdio/logger": "8.38.0",
38
- "@wdio/types": "8.39.0",
39
- "@wdio/utils": "8.40.2",
38
+ "@wdio/types": "8.40.3",
39
+ "@wdio/utils": "8.40.3",
40
40
  "get-port": "^7.0.0",
41
41
  "import-meta-resolve": "^4.0.0",
42
42
  "param-case": "^4.0.0",
43
- "webdriverio": "8.40.2"
43
+ "tree-kill": "^1.2.2",
44
+ "webdriverio": "8.40.3"
44
45
  },
45
46
  "publishConfig": {
46
47
  "access": "public"
47
48
  },
48
- "gitHead": "4cade71f6be0b8c53c48918b9a6da37a6ad21835"
49
+ "gitHead": "2e38de6f7728abb5a049869a36d471664e16d0e2"
49
50
  }