velocious 1.0.52 → 1.0.54
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/package.json
CHANGED
|
@@ -145,7 +145,7 @@ export default class TestRunner {
|
|
|
145
145
|
} catch (error) {
|
|
146
146
|
this._failedTests++
|
|
147
147
|
|
|
148
|
-
|
|
148
|
+
console.error(`${leftPadding} Test failed: ${error.message}`)
|
|
149
149
|
addTrackedStackToError(error)
|
|
150
150
|
|
|
151
151
|
const backtraceCleaner = new BacktraceCleaner(error)
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {AsyncLocalStorage} from "async_hooks"
|
|
2
|
+
|
|
3
|
+
let asyncLocalStorage
|
|
4
|
+
|
|
5
|
+
if (AsyncLocalStorage) {
|
|
6
|
+
asyncLocalStorage = new AsyncLocalStorage()
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function addTrackedStackToError(error) {
|
|
10
|
+
// Not supported
|
|
11
|
+
if (!asyncLocalStorage) return
|
|
12
|
+
|
|
13
|
+
const parentStacks = asyncLocalStorage.getStore() || []
|
|
14
|
+
const additionalStackLines = []
|
|
15
|
+
|
|
16
|
+
for (const parentStack of parentStacks) {
|
|
17
|
+
for (const parentStackLine of parentStack) {
|
|
18
|
+
additionalStackLines.push(parentStackLine)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Replace the error message on the first line with this string
|
|
23
|
+
error.stack += "\n" + additionalStackLines.join("\n")
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function withTrackedStack(arg1, arg2) {
|
|
27
|
+
let callback, stack
|
|
28
|
+
|
|
29
|
+
if (arg2) {
|
|
30
|
+
callback = arg2
|
|
31
|
+
stack = arg1
|
|
32
|
+
} else {
|
|
33
|
+
callback = arg1
|
|
34
|
+
stack = Error().stack
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Not supported
|
|
38
|
+
if (!asyncLocalStorage) return await callback()
|
|
39
|
+
|
|
40
|
+
const parentStacks = asyncLocalStorage.getStore() || []
|
|
41
|
+
const additionalStackLines = []
|
|
42
|
+
const currentStackLines = stack.split("\n")
|
|
43
|
+
|
|
44
|
+
currentStackLines[0] = " [WITH TRACKED STACK]"
|
|
45
|
+
|
|
46
|
+
for (let i = currentStackLines.length; i >= 0; i--) {
|
|
47
|
+
const stackLine = currentStackLines[i]
|
|
48
|
+
|
|
49
|
+
additionalStackLines.unshift(stackLine)
|
|
50
|
+
|
|
51
|
+
if (stackLine == " [WITH TRACKED STACK]") {
|
|
52
|
+
break
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const newStacks = [additionalStackLines, ...parentStacks]
|
|
57
|
+
|
|
58
|
+
await asyncLocalStorage.run(newStacks, async () => {
|
|
59
|
+
return await callback()
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (globalThis.withTrackedStack) {
|
|
64
|
+
console.warn("globalThis.withTrackedStack was already defined")
|
|
65
|
+
} else {
|
|
66
|
+
globalThis.withTrackedStack = {addTrackedStackToError, withTrackedStack}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export {addTrackedStackToError, withTrackedStack}
|
|
@@ -1,63 +1,23 @@
|
|
|
1
|
-
import {AsyncLocalStorage} from "async_hooks"
|
|
2
|
-
|
|
3
|
-
let asyncLocalStorage
|
|
4
|
-
|
|
5
|
-
if (AsyncLocalStorage) {
|
|
6
|
-
asyncLocalStorage = new AsyncLocalStorage()
|
|
7
|
-
}
|
|
8
|
-
|
|
9
1
|
function addTrackedStackToError(error) {
|
|
10
|
-
|
|
11
|
-
if (!asyncLocalStorage) return
|
|
12
|
-
|
|
13
|
-
const parentStacks = asyncLocalStorage.getStore() || []
|
|
14
|
-
const additionalStackLines = []
|
|
15
|
-
|
|
16
|
-
for (const parentStack of parentStacks) {
|
|
17
|
-
for (const parentStackLine of parentStack) {
|
|
18
|
-
additionalStackLines.push(parentStackLine)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Replace the error message on the first line with this string
|
|
23
|
-
error.stack += "\n" + additionalStackLines.join("\n")
|
|
2
|
+
globalThis.withTrackedStack?.addTrackedStackToError(error)
|
|
24
3
|
}
|
|
25
4
|
|
|
26
|
-
async function withTrackedStack(
|
|
27
|
-
|
|
5
|
+
async function withTrackedStack(...args) {
|
|
6
|
+
const withTrackedStack = globalThis.withTrackedStack?.withTrackedStack
|
|
28
7
|
|
|
29
|
-
|
|
30
|
-
callback = arg2
|
|
31
|
-
stack = arg1
|
|
32
|
-
} else {
|
|
33
|
-
callback = arg1
|
|
34
|
-
stack = Error().stack
|
|
35
|
-
}
|
|
8
|
+
let callback
|
|
36
9
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const additionalStackLines = []
|
|
42
|
-
const currentStackLines = stack.split("\n")
|
|
43
|
-
|
|
44
|
-
currentStackLines[0] = " [WITH TRACKED STACK]"
|
|
45
|
-
|
|
46
|
-
for (let i = currentStackLines.length; i >= 0; i--) {
|
|
47
|
-
const stackLine = currentStackLines[i]
|
|
48
|
-
|
|
49
|
-
additionalStackLines.unshift(stackLine)
|
|
50
|
-
|
|
51
|
-
if (stackLine == " [WITH TRACKED STACK]") {
|
|
52
|
-
break
|
|
53
|
-
}
|
|
10
|
+
if (args[1]) {
|
|
11
|
+
callback = args[1]
|
|
12
|
+
} else {
|
|
13
|
+
callback = args[0]
|
|
54
14
|
}
|
|
55
15
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
16
|
+
if (withTrackedStack) {
|
|
17
|
+
return await withTrackedStack(...args)
|
|
18
|
+
} else {
|
|
59
19
|
return await callback()
|
|
60
|
-
}
|
|
20
|
+
}
|
|
61
21
|
}
|
|
62
22
|
|
|
63
23
|
export {addTrackedStackToError, withTrackedStack}
|