@appland/scanner 1.84.0 → 1.85.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [@appland/scanner-v1.85.0](https://github.com/getappmap/appmap-js/compare/@appland/scanner-v1.84.1...@appland/scanner-v1.85.0) (2023-12-28)
2
+
3
+
4
+ ### Features
5
+
6
+ * Scanner rule for unfulfilled promises ([df6afe8](https://github.com/getappmap/appmap-js/commit/df6afe8e2cbc1f677ad1313309fb365971806204)), closes [#1477](https://github.com/getappmap/appmap-js/issues/1477)
7
+
8
+ # [@appland/scanner-v1.84.1](https://github.com/getappmap/appmap-js/compare/@appland/scanner-v1.84.0...@appland/scanner-v1.84.1) (2023-11-08)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * Catch and report errors that occur in the matcher function ([b558170](https://github.com/getappmap/appmap-js/commit/b558170aa49c3b874c5b46f504a1db1a0120bacb))
14
+
1
15
  # [@appland/scanner-v1.84.0](https://github.com/getappmap/appmap-js/compare/@appland/scanner-v1.83.1...@appland/scanner-v1.84.0) (2023-11-07)
2
16
 
3
17
 
package/LICENSE.txt CHANGED
@@ -12,7 +12,7 @@ Software: @appland/scanner
12
12
 
13
13
  License: MIT License
14
14
 
15
- Copyright 2022, AppLand Inc
15
+ Copyright 2023, AppLand Inc
16
16
 
17
17
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
18
18
  to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
@@ -231,7 +231,13 @@ class RuleChecker {
231
231
  });
232
232
  if (this.progress)
233
233
  yield this.progress.matchEvent(event, appMapIndex);
234
- const matchResult = yield checkInstance.ruleLogic.matcher(event, appMapIndex, checkInstance.filterEvent.bind(checkInstance));
234
+ let matchResult;
235
+ try {
236
+ matchResult = yield checkInstance.ruleLogic.matcher(event, appMapIndex, checkInstance.filterEvent.bind(checkInstance));
237
+ }
238
+ catch (e) {
239
+ (0, console_1.warn)(e);
240
+ }
235
241
  if (this.progress)
236
242
  yield this.progress.matchResult(event, matchResult);
237
243
  const numFindings = findings.length;
@@ -0,0 +1,3 @@
1
+ import type RuleInstance from '../ruleInstance';
2
+ declare const RULE: RuleInstance;
3
+ export default RULE;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
7
+ const id = 'unfulfilled-promise';
8
+ const RULE = {
9
+ id,
10
+ title: 'Unfulfilled Promise',
11
+ description: (0, parseRuleDescription_1.default)(id),
12
+ enumerateScope: true,
13
+ build: () => ({ matcher: (e) => { var _a; return ((_a = e.returnValue) === null || _a === void 0 ? void 0 : _a.value) === 'Promise { <pending> }'; } }),
14
+ };
15
+ exports.default = RULE;
@@ -0,0 +1,48 @@
1
+ ---
2
+ rule: unfulfilled-promise
3
+ name: Unfulfilled promise
4
+ title: Unfulfilled Promise
5
+ ---
6
+
7
+ Finds promises which have been created during the recording but have remained unfulfilled at the
8
+ end.
9
+
10
+ ### Rule logic
11
+
12
+ The rule simply looks for return events with value of `Promise { <pending> }` without a subsequent
13
+ update.
14
+
15
+ ### Notes
16
+
17
+ `Promise { <pending> }` is a special value used by the appmap-node agent to represent promises that
18
+ haven't been fulfilled yet. Normally, once the promise is fulfilled, an event update is added to the
19
+ AppMap with the resolved value and total elapsed run time.
20
+
21
+ However, if a promise remains unfulfilled when the recording ends (for example when a HTTP response
22
+ is sent or a test case finishes) this pending state is never updated.
23
+
24
+ Most of the time it means some asynchronous computation has been started and its results not awaited
25
+ for and therefore not collected; such computations should be removed or the results awaited.
26
+
27
+ In some cases this is an intended behaviour; for example, a background book-keeping or cleanup
28
+ process might be started which doesn't directly impact the results of the operation that triggered
29
+ it. Note that during testing such processes should still run to completion before a test case
30
+ finishes (or else be suppressed altogether); otherwise there might be unintended interference
31
+ between test cases leading to brittle tests. Each test case should start from a known, clean and
32
+ quiescent environment.
33
+
34
+ ### Resolution
35
+
36
+ Identify where the promise is created and make sure to `await` on it. Even when the result is void,
37
+ some other part of the program might assume the asynchronous computation has completed. Without
38
+ awaiting it at that point a race condition can result, leading to intermittent stability issues.
39
+
40
+ ### Options
41
+
42
+ None
43
+
44
+ ### Examples
45
+
46
+ ```yaml
47
+ - rule: unfulfilledPromise
48
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appland/scanner",
3
- "version": "1.84.0",
3
+ "version": "1.85.0",
4
4
  "description": "Analyze AppMaps for code flaws",
5
5
  "bin": "built/cli.js",
6
6
  "main": "built/index.js",