@itwin/build-tools 3.0.0-dev.89 → 3.0.0-dev.93

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,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  /* eslint-disable @typescript-eslint/naming-convention */
9
9
  /* eslint-disable @typescript-eslint/no-var-requires */
10
10
  /* eslint-disable no-console */
11
+ const debugLeaks = process.env.DEBUG_LEAKS;
12
+ if (debugLeaks)
13
+ require("wtfnode");
11
14
  const path = require("path");
12
15
  const fs = require("fs-extra");
13
16
  const { logBuildWarning, logBuildError, failBuild } = require("../scripts/rush/utils");
@@ -54,6 +57,24 @@ class BentleyMochaReporter extends Spec {
54
57
  failBuild();
55
58
  }
56
59
  }
60
+ // Detect hangs caused by tests that leave timers/other handles open - not possible in electron frontends.
61
+ if (!("electron" in process.versions)) {
62
+ // NB: By calling unref() on this timer, we stop it from keeping the process alive, so it will only fire if _something else_ is still keeping
63
+ // the process alive after 5 seconds. This also has the benefit of preventing the timer from showing up in wtfnode's dump of open handles.
64
+ setTimeout(() => {
65
+ logBuildError(`Handle leak detected. Node was still running 5 seconds after tests completed.`);
66
+ if (debugLeaks) {
67
+ const wtf = require("wtfnode");
68
+ wtf.setLogger("info", console.error);
69
+ wtf.dump();
70
+ }
71
+ else {
72
+ console.error("Try running with the DEBUG_LEAKS env var set to see open handles.");
73
+ }
74
+ // Not sure why, but process.exit(1) wasn't working here...
75
+ process.kill(process.pid);
76
+ }, 5000).unref();
77
+ }
57
78
  if (!this.stats.pending)
58
79
  return;
59
80
  // Also log warnings in CI builds when tests have been skipped.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/build-tools",
3
- "version": "3.0.0-dev.89",
3
+ "version": "3.0.0-dev.93",
4
4
  "description": "Bentley build tools",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -36,10 +36,11 @@
36
36
  "typedoc-plugin-external-module-name": "3.0.0",
37
37
  "typedoc-plugin-internal-external": "2.1.1",
38
38
  "typescript": "~4.4.0",
39
+ "wtfnode": "^0.9.1",
39
40
  "yargs": "^16.0.0"
40
41
  },
41
42
  "devDependencies": {
42
- "@itwin/eslint-plugin": "3.0.0-dev.89",
43
+ "@itwin/eslint-plugin": "3.0.0-dev.93",
43
44
  "@types/node": "14.14.31",
44
45
  "eslint": "^7.11.0"
45
46
  },
@@ -53,8 +54,8 @@
53
54
  }
54
55
  },
55
56
  "scripts": {
56
- "compile": "npm run -s build",
57
57
  "build": "tsc 1>&2",
58
+ "build:ci": "npm run -s build",
58
59
  "clean": "rimraf ../../modules .rush/temp/package-deps*.json",
59
60
  "docs": "",
60
61
  "lint": "eslint -f visualstudio --config package.json --no-eslintrc \"./src/**/*.ts\" 1>&2",