@wdio/local-runner 9.32.0-alpha.6 → 10.0.0-alpha.18

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.
package/build/index.js CHANGED
@@ -6,6 +6,7 @@ import { XvfbManager } from "@wdio/xvfb";
6
6
  // src/worker.ts
7
7
  import url from "node:url";
8
8
  import path from "node:path";
9
+ import { constants } from "node:os";
9
10
  import { EventEmitter } from "node:events";
10
11
  import { ProcessFactory } from "@wdio/xvfb";
11
12
  import logger from "@wdio/logger";
@@ -186,6 +187,13 @@ var stdOutStream = new RunnerStream();
186
187
  var stdErrStream = new RunnerStream();
187
188
  stdOutStream.pipe(process.stdout);
188
189
  stdErrStream.pipe(process.stderr);
190
+ var GRACEFUL_SHUTDOWN_SIGNALS = ["SIGTERM", "SIGINT"];
191
+ var SIGNAL_EXIT_CODE_OFFSET = 128;
192
+ var UNKNOWN_SIGNAL_EXIT_CODE = 1;
193
+ function getExitCodeForSignal(signal) {
194
+ const signalNumber = signal ? constants.signals[signal] : void 0;
195
+ return signalNumber ? SIGNAL_EXIT_CODE_OFFSET + signalNumber : UNKNOWN_SIGNAL_EXIT_CODE;
196
+ }
189
197
  var WorkerInstance = class extends EventEmitter {
190
198
  cid;
191
199
  config;
@@ -251,9 +259,7 @@ var WorkerInstance = class extends EventEmitter {
251
259
  async startProcess() {
252
260
  const { cid, execArgv } = this;
253
261
  const argv = process.argv.slice(2);
254
- const runnerEnv = Object.assign({
255
- NODE_OPTIONS: "--enable-source-maps"
256
- }, process.env, this.config.runnerEnv, {
262
+ const runnerEnv = Object.assign({}, process.env, this.config.runnerEnv, {
257
263
  WDIO_WORKER_ID: cid,
258
264
  NODE_ENV: process.env.NODE_ENV || "test"
259
265
  });
@@ -265,7 +271,9 @@ var WorkerInstance = class extends EventEmitter {
265
271
  }
266
272
  runnerEnv.WDIO_LOG_PATH = path.join(this.config.outputDir, logFileRunner);
267
273
  }
268
- runnerEnv.NODE_OPTIONS = process.env.NODE_OPTIONS + " " + (runnerEnv.NODE_OPTIONS || "");
274
+ const nodeOptions = (runnerEnv.NODE_OPTIONS ?? "").trim();
275
+ const hasSourceMaps = nodeOptions.split(" ").includes("--enable-source-maps");
276
+ runnerEnv.NODE_OPTIONS = hasSourceMaps ? nodeOptions : `${nodeOptions} --enable-source-maps`.trim();
269
277
  log.info(`Start worker ${cid} with arg: ${argv.join(" ")}`);
270
278
  const childProcess = this.childProcess = await this.#processFactory.createWorkerProcess(
271
279
  path.join(__dirname, "run.js"),
@@ -336,13 +344,27 @@ var WorkerInstance = class extends EventEmitter {
336
344
  const { cid } = this;
337
345
  this.emit("error", Object.assign(payload, { cid }));
338
346
  }
339
- _handleExit(exitCode) {
347
+ /**
348
+ * Node calls this with `(code, signal)` where `code` is `null` whenever the
349
+ * worker was terminated by a signal rather than exiting on its own, e.g. on
350
+ * a segmentation fault. Only the second argument identifies that case.
351
+ */
352
+ _handleExit(exitCode, signal = null) {
340
353
  const { cid, childProcess, specs, retries } = this;
354
+ const wasKilledIntentionally = this.isKilled;
341
355
  delete this.childProcess;
342
356
  this.isBusy = false;
343
357
  this.isKilled = true;
344
- log.debug(`Runner ${cid} finished with exit code ${exitCode}`);
345
- this.emit("exit", { cid, exitCode, specs, retries });
358
+ const resolvedExitCode = exitCode ?? getExitCodeForSignal(signal);
359
+ const crashed = signal !== null && !wasKilledIntentionally && !GRACEFUL_SHUTDOWN_SIGNALS.includes(signal);
360
+ if (crashed) {
361
+ log.error(
362
+ `Runner ${cid} was terminated by ${signal} and did not report an exit code. The spec file(s) ${specs.join(", ")} are reported as failed with exit code ${resolvedExitCode}. This usually means the process ran out of memory or a native module crashed.`
363
+ );
364
+ } else {
365
+ log.debug(`Runner ${cid} finished with exit code ${resolvedExitCode}`);
366
+ }
367
+ this.emit("exit", { cid, exitCode: resolvedExitCode, specs, retries, signal });
346
368
  if (childProcess) {
347
369
  childProcess.kill("SIGTERM");
348
370
  }
package/build/worker.d.ts CHANGED
@@ -52,6 +52,11 @@ export default class WorkerInstance extends EventEmitter implements Workers.Work
52
52
  startProcess(): Promise<ChildProcess>;
53
53
  private _handleMessage;
54
54
  private _handleError;
55
+ /**
56
+ * Node calls this with `(code, signal)` where `code` is `null` whenever the
57
+ * worker was terminated by a signal rather than exiting on its own, e.g. on
58
+ * a segmentation fault. Only the second argument identifies that case.
59
+ */
55
60
  private _handleExit;
56
61
  /**
57
62
  * Forcefully kill the worker process.
@@ -1 +1 @@
1
- {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAmB1C;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,YAAa,YAAW,OAAO,CAAC,MAAM;;IAC9E,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,WAAW,CAAC,MAAM,CAAA;IAC1B,UAAU,EAAE,MAAM,CAAA;IAElB,IAAI,EAAE,WAAW,CAAC,YAAY,CAAA;IAE9B,YAAY,EAAE,WAAW,CAAC,YAAY,CAAA;IACtC,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,oBAAoB,CAAA;IAC5B,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,cA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O,CAAC,KAAK,IAAI,CAAW;IAE3E;;;;;;;;;;OAUG;gBAEC,MAAM,EAAE,WAAW,CAAC,MAAM,EAC1B,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,gBAAgB,EAC7E,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,oBAAoB,EAC5B,WAAW,EAAE,WAAW;IAmB5B;;OAEG;IACG,YAAY;IA2ElB,OAAO,CAAC,cAAc;IAqEtB,OAAO,CAAC,YAAY;IAKpB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAmCnB;;;;;;OAMG;IACH,IAAI,CAAC,MAAM,GAAE,MAAM,CAAC,OAAmB,GAAG,IAAI;IAiB9C;;;;OAIG;IACG,WAAW,CAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,iBAAiB,EAAE,aAAa,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CA4B7G"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/local-runner",
3
- "version": "9.32.0-alpha.6+3d8818a67",
3
+ "version": "10.0.0-alpha.18+dbf0f4971",
4
4
  "description": "A WebdriverIO runner to run tests locally",
5
5
  "author": "Christian Bromann <mail@bromann.dev>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-local-runner",
@@ -37,13 +37,13 @@
37
37
  "typeScriptVersion": "3.8.3",
38
38
  "dependencies": {
39
39
  "@types/node": "^20.1.0",
40
- "@wdio/logger": "9.32.0-alpha.6+3d8818a67",
41
- "@wdio/repl": "9.32.0-alpha.6+3d8818a67",
42
- "@wdio/runner": "9.32.0-alpha.6+3d8818a67",
43
- "@wdio/types": "9.32.0-alpha.6+3d8818a67",
44
- "@wdio/xvfb": "9.32.0-alpha.6+3d8818a67",
40
+ "@wdio/logger": "9.29.1",
41
+ "@wdio/repl": "9.16.2",
42
+ "@wdio/runner": "10.0.0-alpha.18+dbf0f4971",
43
+ "@wdio/types": "9.32.0",
44
+ "@wdio/xvfb": "9.32.0",
45
45
  "exit-hook": "^4.0.0",
46
- "expect-webdriverio": "^6.0.9",
46
+ "expect-webdriverio": "^7.0.1",
47
47
  "split2": "^4.1.0",
48
48
  "stream-buffers": "^3.0.2"
49
49
  },
@@ -53,5 +53,5 @@
53
53
  "publishConfig": {
54
54
  "access": "public"
55
55
  },
56
- "gitHead": "3d8818a67404f0b5d4b81eda877ffad1f4d317c0"
56
+ "gitHead": "dbf0f497130676040ce4212d9cf6459adfe16c42"
57
57
  }