@nestjs/observe 0.3.24 → 0.3.26
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/README.md +26 -1
- package/dist/agent/detached-observe-worker.js +50 -6
- package/dist/agent/observe-agent.shared-buffer.d.ts +44 -0
- package/dist/agent/observe-agent.shared-buffer.js +196 -19
- package/dist/agent/observe-agent.worker.d.ts +22 -2
- package/dist/agent/observe-agent.worker.js +43 -7
- package/dist/agent/telemetry-wire-contract.js +7 -1
- package/dist/cli/agent-notes.js +16 -4
- package/dist/cli/link.js +28 -3
- package/dist/cli/observe-cli.js +1 -19
- package/dist/cli/open-url.d.ts +27 -0
- package/dist/cli/open-url.js +63 -0
- package/dist/cli/project-files.d.ts +42 -1
- package/dist/cli/project-files.js +146 -7
- package/dist/cli/project-setup.d.ts +6 -0
- package/dist/cli/project-setup.js +14 -1
- package/dist/cli/wire-application.js +6 -0
- package/dist/custom-metrics/counter.d.ts +13 -2
- package/dist/custom-metrics/counter.js +33 -16
- package/dist/custom-metrics/finite-value.util.d.ts +14 -0
- package/dist/custom-metrics/finite-value.util.js +33 -1
- package/dist/custom-metrics/gauge.d.ts +2 -0
- package/dist/custom-metrics/gauge.js +43 -21
- package/dist/custom-metrics/label-values.util.d.ts +37 -0
- package/dist/custom-metrics/label-values.util.js +51 -0
- package/dist/custom-metrics/summary.d.ts +23 -0
- package/dist/custom-metrics/summary.js +73 -2
- package/dist/instrument/create-instance-decorator.instrument.js +244 -97
- package/dist/interfaces/observe-options.interface.d.ts +3 -1
- package/dist/objectives/objectives.registry.js +12 -0
- package/dist/observe.module.js +119 -3
- package/dist/otlp/otlp-encoders.js +22 -5
- package/dist/otlp/otlp-span.mapper.d.ts +4 -3
- package/dist/otlp/otlp-span.mapper.js +16 -8
- package/dist/otlp/otlp-trace-exporter.service.d.ts +3 -0
- package/dist/otlp/otlp-trace-exporter.service.js +71 -6
- package/dist/outgoing/http.integration.d.ts +8 -4
- package/dist/outgoing/http.integration.js +13 -6
- package/dist/outgoing/llm/llm-fetch.integration.js +62 -1
- package/dist/outgoing/llm/llm-providers.d.ts +16 -4
- package/dist/outgoing/llm/llm-providers.js +72 -22
- package/dist/outgoing/llm/llm-usage.d.ts +11 -6
- package/dist/outgoing/llm/llm-usage.js +72 -25
- package/dist/outgoing/mssql.integration.js +16 -2
- package/dist/outgoing/mysql2.integration.js +17 -1
- package/dist/outgoing/outgoing-observe-agent.service.js +15 -3
- package/dist/outgoing/outgoing-span.recorder.js +17 -3
- package/dist/outgoing/pg.integration.d.ts +3 -2
- package/dist/outgoing/pg.integration.js +39 -11
- package/dist/outgoing/sql-statement.util.js +106 -14
- package/dist/outgoing/undici.integration.d.ts +13 -0
- package/dist/outgoing/undici.integration.js +68 -0
- package/dist/protocols/bull-observe-agent.service.js +2 -12
- package/dist/protocols/deferred-trace-completion.d.ts +9 -1
- package/dist/protocols/deferred-trace-completion.js +36 -6
- package/dist/protocols/graphql-observe-agent.service.d.ts +36 -5
- package/dist/protocols/graphql-observe-agent.service.js +166 -5
- package/dist/protocols/graphql-operation-parser.js +72 -18
- package/dist/protocols/http-observe-agent.service.d.ts +43 -9
- package/dist/protocols/http-observe-agent.service.js +177 -59
- package/dist/protocols/job-trace-runner.d.ts +35 -3
- package/dist/protocols/job-trace-runner.js +136 -31
- package/dist/protocols/queue-observe-agent.service.js +44 -20
- package/dist/protocols/rpc-observe-agent.service.d.ts +50 -8
- package/dist/protocols/rpc-observe-agent.service.js +225 -49
- package/dist/protocols/ws-observe-agent.service.d.ts +55 -5
- package/dist/protocols/ws-observe-agent.service.js +226 -20
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/logger-patcher.service.js +3 -4
- package/dist/services/operation-trace.registry.d.ts +45 -1
- package/dist/services/operation-trace.registry.js +418 -35
- package/dist/services/stdout-forwarder.service.d.ts +69 -0
- package/dist/services/stdout-forwarder.service.js +288 -51
- package/dist/services/tracer.service.d.ts +23 -0
- package/dist/services/tracer.service.js +99 -7
- package/dist/utils/capture-request.util.d.ts +3 -1
- package/dist/utils/capture-request.util.js +100 -12
- package/dist/utils/fit-to-length.util.js +33 -10
- package/dist/utils/log-line.parser.d.ts +14 -0
- package/dist/utils/log-line.parser.js +7 -3
- package/dist/utils/log-redactor.d.ts +14 -0
- package/dist/utils/log-redactor.js +512 -61
- package/dist/utils/operation-state.util.d.ts +39 -0
- package/dist/utils/operation-state.util.js +50 -0
- package/dist/utils/redact-url-query.d.ts +26 -4
- package/dist/utils/redact-url-query.js +184 -32
- package/dist/utils/sensitive-keys.d.ts +4 -1
- package/dist/utils/sensitive-keys.js +48 -10
- package/dist/utils/shared-hook-slot.util.d.ts +48 -0
- package/dist/utils/shared-hook-slot.util.js +103 -0
- package/dist/utils/source-context.util.d.ts +8 -0
- package/dist/utils/source-context.util.js +88 -19
- package/dist/utils/source-map-resolver.util.js +8 -2
- package/dist/utils/trace-context.util.d.ts +20 -0
- package/dist/utils/trace-context.util.js +50 -6
- package/package.json +4 -1
|
@@ -11,25 +11,119 @@ const TABLE_AFTER = {
|
|
|
11
11
|
REPLACE: /\bINTO\s+([\w."`[\]]+)/i,
|
|
12
12
|
UPDATE: /^\s*UPDATE\s+(?:ONLY\s+)?([\w."`[\]]+)/i,
|
|
13
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Words that put a table or a subquery, not a function's arguments, in the
|
|
16
|
+
* parenthesis after them.
|
|
17
|
+
*/
|
|
18
|
+
const NOT_A_FUNCTION = new Set([
|
|
19
|
+
"ALL",
|
|
20
|
+
"AND",
|
|
21
|
+
"ANY",
|
|
22
|
+
"AS",
|
|
23
|
+
"EXCEPT",
|
|
24
|
+
"EXISTS",
|
|
25
|
+
"FROM",
|
|
26
|
+
"IN",
|
|
27
|
+
"INTERSECT",
|
|
28
|
+
"JOIN",
|
|
29
|
+
"LATERAL",
|
|
30
|
+
"NOT",
|
|
31
|
+
"ON",
|
|
32
|
+
"OR",
|
|
33
|
+
"SELECT",
|
|
34
|
+
"SOME",
|
|
35
|
+
"UNION",
|
|
36
|
+
"USING",
|
|
37
|
+
"VALUES",
|
|
38
|
+
"WHERE",
|
|
39
|
+
"WITH",
|
|
40
|
+
]);
|
|
41
|
+
/** Whether the parenthesis at `index` opens a function's arguments. */
|
|
42
|
+
function opensArguments(statement, index) {
|
|
43
|
+
let end = index;
|
|
44
|
+
if (statement[end - 1] === " ") {
|
|
45
|
+
end--;
|
|
46
|
+
}
|
|
47
|
+
let start = end;
|
|
48
|
+
while (start > 0 && /[\w$]/.test(statement[start - 1])) {
|
|
49
|
+
start--;
|
|
50
|
+
}
|
|
51
|
+
return (start < end &&
|
|
52
|
+
/^[A-Za-z_]/.test(statement[start]) &&
|
|
53
|
+
!NOT_A_FUNCTION.has(statement.slice(start, end).toUpperCase()));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* `statement` with what a function's arguments hold left out:
|
|
57
|
+
* `EXTRACT(EPOCH FROM created_at)` and `TRIM(BOTH ' ' FROM name)` have a
|
|
58
|
+
* `FROM` that is an argument, not the table. A parenthesis counts as one when
|
|
59
|
+
* a name comes right before it. One after `FROM` or `JOIN` - a derived table,
|
|
60
|
+
* a subquery, a parenthesised join - is kept as it is. Only what a function
|
|
61
|
+
* holds is taken out, so every `FROM` left is followed by what followed it
|
|
62
|
+
* before. One pass, so it stays linear however deeply the parentheses nest.
|
|
63
|
+
*/
|
|
64
|
+
function withoutFunctionArguments(statement) {
|
|
65
|
+
let text = "";
|
|
66
|
+
let copied = 0;
|
|
67
|
+
// How deep inside a function's arguments `index` is, 0 outside any.
|
|
68
|
+
let depth = 0;
|
|
69
|
+
for (let index = 0; index < statement.length; index++) {
|
|
70
|
+
const char = statement[index];
|
|
71
|
+
if (char === "(") {
|
|
72
|
+
if (depth) {
|
|
73
|
+
depth++;
|
|
74
|
+
}
|
|
75
|
+
else if (opensArguments(statement, index)) {
|
|
76
|
+
text += statement.slice(copied, index);
|
|
77
|
+
copied = index;
|
|
78
|
+
depth = 1;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else if (char === ")" && depth && !--depth) {
|
|
82
|
+
text += "()";
|
|
83
|
+
copied = index + 1;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Arguments that never close are kept as they are.
|
|
87
|
+
return text + statement.slice(copied);
|
|
88
|
+
}
|
|
14
89
|
/**
|
|
15
90
|
* Comments, quoted names and literals, found left to right: a comment marker
|
|
16
91
|
* inside a string, or a quote inside a comment or a name, is part of the token
|
|
17
92
|
* it is in. Each runs to the end of the input when nothing closes it. Names
|
|
18
93
|
* are kept, comments become a space and literals `?`.
|
|
19
94
|
*
|
|
20
|
-
* Postgres quotes names in `"
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
95
|
+
* Postgres quotes names in `"` alone. A backtick quotes nothing there: it is
|
|
96
|
+
* a character operators are spelled with (PGroonga's ``&` ``), and what
|
|
97
|
+
* follows it is read like any other text. A plain string takes a backslash
|
|
98
|
+
* as it is and an `E'...'` string as an escape. A dollar quote opens only
|
|
99
|
+
* where a token can start - Postgres reads `a$b$` as one name - and its tag
|
|
100
|
+
* is empty, or a letter, `_` or non-ASCII character followed by any of those
|
|
101
|
+
* or digits, so `$q1$` opens one and `$1` stays a placeholder. Block
|
|
102
|
+
* comments nest, so `/*` is matched alone and its end found by hand.
|
|
24
103
|
*
|
|
25
104
|
* MySQL quotes strings in `"` as well as `'`, as its default sql_mode does
|
|
26
|
-
* (under ANSI_QUOTES a `"` name goes too), with backslash escapes in both
|
|
27
|
-
*
|
|
28
|
-
*
|
|
105
|
+
* (under ANSI_QUOTES a `"` name goes too), with backslash escapes in both,
|
|
106
|
+
* and `#` starts a comment. `--` does
|
|
107
|
+
* only before whitespace or a control character, as MySQL reads it:
|
|
108
|
+
* `credit--5` is `credit - -5`, and the rest of its line is still SQL, quotes
|
|
109
|
+
* and all. Its block comments do not nest.
|
|
29
110
|
*/
|
|
30
111
|
const TOKEN = {
|
|
31
|
-
postgresql: /(?<nested>\/\*)|(?<comment>--[^\n]*)|(?<name>"(?:[^"]|"")*(?:"|$)
|
|
32
|
-
mysql:
|
|
112
|
+
postgresql: /(?<nested>\/\*)|(?<comment>--[^\n]*)|(?<name>"(?:[^"]|"")*(?:"|$))|(?<![\w$])(?<escape>[eE])'(?:[^'\\]|\\[\s\S]?|'')*(?:'|$)|(?<plain>'(?:[^']|'')*(?:'|$))|(?<!\w)\$(?<tag>(?:[A-Za-z_\u0080-\uffff][\w\u0080-\uffff]*)?)\$[\s\S]*?(?:\$\k<tag>\$|$)/g,
|
|
113
|
+
mysql:
|
|
114
|
+
// eslint-disable-next-line no-control-regex -- MySQL's rule for `--`.
|
|
115
|
+
/(?<comment>\/\*[\s\S]*?(?:\*\/|$)|--(?=[\u0000-\u0020\u007f]|$)[^\n]*|#[^\n]*)|(?<name>`(?:[^`]|``)*(?:`|$))|(?<plain>'(?:[^'\\]|\\[\s\S]?|'')*(?:'|$)|"(?:[^"\\]|\\[\s\S]?|"")*(?:"|$))/g,
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* An odd run of backslashes before the quote a string opened with. Whether
|
|
119
|
+
* that quote ends the string is a session setting the statement does not
|
|
120
|
+
* show: Postgres's standard_conforming_strings, MySQL's NO_BACKSLASH_ESCAPES.
|
|
121
|
+
* Read the wrong way, everything after it is out of step - the SQL between
|
|
122
|
+
* literals masked and the literals shipped - so nothing after it is kept.
|
|
123
|
+
*/
|
|
124
|
+
const ESCAPED_QUOTE = {
|
|
125
|
+
"'": /(?<!\\)(?:\\\\)*\\'/,
|
|
126
|
+
'"': /(?<!\\)(?:\\\\)*\\"/,
|
|
33
127
|
};
|
|
34
128
|
function stripLiteralsAndComments(sql, dialect) {
|
|
35
129
|
const token = TOKEN[dialect];
|
|
@@ -49,10 +143,8 @@ function stripLiteralsAndComments(sql, dialect) {
|
|
|
49
143
|
else if (name !== undefined) {
|
|
50
144
|
text += name;
|
|
51
145
|
}
|
|
52
|
-
else if (plain !== undefined &&
|
|
53
|
-
//
|
|
54
|
-
// standard_conforming_strings off, the quote does not end the string
|
|
55
|
-
// here, so where it does end is unknown - and so is everything after.
|
|
146
|
+
else if (plain !== undefined && ESCAPED_QUOTE[plain[0]].test(plain)) {
|
|
147
|
+
// Where this string ends is unknown, and so is everything after it.
|
|
56
148
|
return `${text}?`;
|
|
57
149
|
}
|
|
58
150
|
else {
|
|
@@ -114,7 +206,7 @@ export function describeSanitizedSqlStatement(sql) {
|
|
|
114
206
|
return { operation: "QUERY", statement };
|
|
115
207
|
}
|
|
116
208
|
const table = TABLE_AFTER[verb]
|
|
117
|
-
?.exec(statement)?.[1]
|
|
209
|
+
?.exec(withoutFunctionArguments(statement))?.[1]
|
|
118
210
|
?.replace(/["`[\]]/g, "")
|
|
119
211
|
.slice(0, MAX_IDENTIFIER_LENGTH);
|
|
120
212
|
return { operation: table ? `${verb} ${table}` : verb, statement };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `Dispatcher#dispatch` on undici's base class, which `Agent`, `Pool`,
|
|
3
|
+
* `Client` and the rest share, and which every layer passes a request
|
|
4
|
+
* through.
|
|
5
|
+
*/
|
|
6
|
+
export declare function patchUndiciDispatch(module: unknown): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* `UnwrapHandler.unwrap` on undici 7, which hands each layer below a new
|
|
9
|
+
* wrapper of the handler on every pass: the wrapper is filed under its
|
|
10
|
+
* handler's caller, so a later pass is recognised below a dispatcher
|
|
11
|
+
* composed - its `dispatch` bound - before the base class was patched.
|
|
12
|
+
*/
|
|
13
|
+
export declare function patchUndiciUnwrap(module: unknown): boolean;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { AsyncResource } from "node:async_hooks";
|
|
2
|
+
import { patchMethod } from "./patch-method.util.js";
|
|
3
|
+
/**
|
|
4
|
+
* The async context each request was first dispatched in, by its handler.
|
|
5
|
+
*
|
|
6
|
+
* undici creates a request - and publishes `undici:request:create`, which the
|
|
7
|
+
* HTTP integration reads the caller from - in whatever context the dispatch
|
|
8
|
+
* that gets it to a client runs in. The first pass through `dispatch` is the
|
|
9
|
+
* caller's own call. A later one may run from a socket's events, in the
|
|
10
|
+
* context of whichever request opened that socket: a bounded pool handing a
|
|
11
|
+
* queued request to a client as another one drains, a redirect or a retry
|
|
12
|
+
* re-dispatched from a response. Each later pass is run where the first was.
|
|
13
|
+
*
|
|
14
|
+
* Keyed by handler: undici's own `request`, `stream`, `pipeline` and `fetch`
|
|
15
|
+
* make one per request. An application that calls `dispatch()` itself with
|
|
16
|
+
* one handler for several requests gets them all filed under the first.
|
|
17
|
+
*/
|
|
18
|
+
const callers = new WeakMap();
|
|
19
|
+
/**
|
|
20
|
+
* `Dispatcher#dispatch` on undici's base class, which `Agent`, `Pool`,
|
|
21
|
+
* `Client` and the rest share, and which every layer passes a request
|
|
22
|
+
* through.
|
|
23
|
+
*/
|
|
24
|
+
export function patchUndiciDispatch(module) {
|
|
25
|
+
const base = defaultExport(module);
|
|
26
|
+
return patchMethod(base?.prototype, "dispatch", (original) => function (...args) {
|
|
27
|
+
const handler = args[1];
|
|
28
|
+
if (typeof handler !== "object" || handler === null) {
|
|
29
|
+
return original.apply(this, args);
|
|
30
|
+
}
|
|
31
|
+
const caller = callers.get(handler);
|
|
32
|
+
if (caller) {
|
|
33
|
+
return caller.runInAsyncScope(original, this, ...args);
|
|
34
|
+
}
|
|
35
|
+
callers.set(handler, new AsyncResource("ObserveUndiciDispatch"));
|
|
36
|
+
return original.apply(this, args);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* `UnwrapHandler.unwrap` on undici 7, which hands each layer below a new
|
|
41
|
+
* wrapper of the handler on every pass: the wrapper is filed under its
|
|
42
|
+
* handler's caller, so a later pass is recognised below a dispatcher
|
|
43
|
+
* composed - its `dispatch` bound - before the base class was patched.
|
|
44
|
+
*/
|
|
45
|
+
export function patchUndiciUnwrap(module) {
|
|
46
|
+
const unwrapHandler = defaultExport(module);
|
|
47
|
+
return patchMethod(unwrapHandler, "unwrap", (original) => function (handler) {
|
|
48
|
+
const wrapped = original.call(this, handler);
|
|
49
|
+
if (wrapped !== handler &&
|
|
50
|
+
typeof wrapped === "object" &&
|
|
51
|
+
wrapped !== null &&
|
|
52
|
+
typeof handler === "object" &&
|
|
53
|
+
handler !== null) {
|
|
54
|
+
let caller = callers.get(handler);
|
|
55
|
+
if (!caller) {
|
|
56
|
+
caller = new AsyncResource("ObserveUndiciDispatch");
|
|
57
|
+
callers.set(handler, caller);
|
|
58
|
+
}
|
|
59
|
+
callers.set(wrapped, caller);
|
|
60
|
+
}
|
|
61
|
+
return wrapped;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function defaultExport(module) {
|
|
65
|
+
return typeof module === "function"
|
|
66
|
+
? module
|
|
67
|
+
: module?.default;
|
|
68
|
+
}
|
|
@@ -17,7 +17,7 @@ import { ObserveAgentSharedBuffer } from "../agent/observe-agent.shared-buffer.j
|
|
|
17
17
|
import { OBSERVE_OPTIONS } from "../observe.constants.js";
|
|
18
18
|
import { OperationTraceRegistry } from "../services/operation-trace.registry.js";
|
|
19
19
|
import { describePeerLoadError, loadOptionalPeer, } from "../utils/optional-peer.util.js";
|
|
20
|
-
import { JobTraceRunner } from "./job-trace-runner.js";
|
|
20
|
+
import { JobTraceRunner, readJobTimes } from "./job-trace-runner.js";
|
|
21
21
|
const ORIGINAL_SET_HANDLER = Symbol.for("nestjs.observe.bull.setHandler");
|
|
22
22
|
/** Bull names an unnamed job this; reporting it would name every job the same. */
|
|
23
23
|
const BULL_DEFAULT_JOB_NAME = "__default__";
|
|
@@ -49,17 +49,7 @@ let BullObserveAgentService = BullObserveAgentService_1 = class BullObserveAgent
|
|
|
49
49
|
return result.module?.prototype ?? null;
|
|
50
50
|
}
|
|
51
51
|
readQueueMetadata(job) {
|
|
52
|
-
const metadata =
|
|
53
|
-
if (typeof job.timestamp === "number") {
|
|
54
|
-
metadata.enqueuedAt = new Date(job.timestamp).toISOString();
|
|
55
|
-
const startedAt = typeof job.processedOn === "number" ? job.processedOn : Date.now();
|
|
56
|
-
// As with BullMQ: a delay the caller asked for is a schedule, not a
|
|
57
|
-
// backlog, so the wait is measured from when the job became runnable.
|
|
58
|
-
// `||`, not `??`: the job's own `delay` reads 0 once Bull has promoted
|
|
59
|
-
// it, and only the options still say what was asked for.
|
|
60
|
-
const delay = job.delay || job.opts?.delay || 0;
|
|
61
|
-
metadata.waitDuration = Math.max(0, startedAt - (job.timestamp + delay));
|
|
62
|
-
}
|
|
52
|
+
const metadata = readJobTimes(job);
|
|
63
53
|
if (typeof job.attemptsMade === "number") {
|
|
64
54
|
metadata.attemptsMade = job.attemptsMade;
|
|
65
55
|
}
|
|
@@ -21,7 +21,15 @@ export declare function setAttributesSafely<TArgs extends unknown[]>(callback: (
|
|
|
21
21
|
* have been written to keep out is not a safe guess.
|
|
22
22
|
*/
|
|
23
23
|
export declare function shouldIgnoreSafely<TArgs extends unknown[]>(callback: ((...args: TArgs) => boolean) | undefined, args: TArgs, receiver: unknown, logger: Logger, transport: string): boolean;
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* A bad identity callback must not prevent the trace from being closed.
|
|
26
|
+
*
|
|
27
|
+
* Made a string here, inside the guard, rather than by whoever records it: a
|
|
28
|
+
* callback typed to return a string can still hand back what a message
|
|
29
|
+
* carried - a TCP packet's metadata is whatever `JSON.parse` made of it - and
|
|
30
|
+
* `String()` throws on `{"toString": 1}`. Thrown between ending the trace and
|
|
31
|
+
* plucking it, that left the trace registered for the life of the process.
|
|
32
|
+
*/
|
|
25
33
|
export declare function getUserIdSafely<TArgs extends unknown[]>(callback: ((...args: TArgs) => string | undefined) | undefined, args: TArgs, receiver: unknown, logger: Logger, transport: string): string | undefined;
|
|
26
34
|
/**
|
|
27
35
|
* Completes a trace once its operation has ended, without ever leaking a
|
|
@@ -30,13 +30,22 @@ export function invokeUserCallbackSafely(callback, args, receiver, fallback, log
|
|
|
30
30
|
return callback.apply(receiver, args);
|
|
31
31
|
}
|
|
32
32
|
catch (error) {
|
|
33
|
-
|
|
34
|
-
reportedCallbacks.add(callback);
|
|
35
|
-
warnSafely(logger, `"${name}" threw; ${outcome}. Later failures are not reported: ${describeFailure(error)}`);
|
|
36
|
-
}
|
|
33
|
+
reportCallbackFailure(callback, logger, name, "threw", outcome, error);
|
|
37
34
|
return fallback();
|
|
38
35
|
}
|
|
39
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Reports the first failure of a callback, whichever way it failed: a
|
|
39
|
+
* callback that both throws and returns what cannot be used still says so
|
|
40
|
+
* once.
|
|
41
|
+
*/
|
|
42
|
+
function reportCallbackFailure(callback, logger, name, failure, outcome, error) {
|
|
43
|
+
if (reportedCallbacks.has(callback)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
reportedCallbacks.add(callback);
|
|
47
|
+
warnSafely(logger, `"${name}" ${failure}; ${outcome}. Later failures are not reported: ${describeFailure(error)}`);
|
|
48
|
+
}
|
|
40
49
|
/**
|
|
41
50
|
* The trace id for an operation. A generator that throws is replaced by a
|
|
42
51
|
* fresh uuidv7, which no open trace can share, so the operation is still
|
|
@@ -69,12 +78,33 @@ export function shouldIgnoreSafely(callback, args, receiver, logger, transport)
|
|
|
69
78
|
}
|
|
70
79
|
return invokeUserCallbackSafely(callback, args, receiver, () => true, logger, `${transport}.ignore`, "not tracing the operation");
|
|
71
80
|
}
|
|
72
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* A bad identity callback must not prevent the trace from being closed.
|
|
83
|
+
*
|
|
84
|
+
* Made a string here, inside the guard, rather than by whoever records it: a
|
|
85
|
+
* callback typed to return a string can still hand back what a message
|
|
86
|
+
* carried - a TCP packet's metadata is whatever `JSON.parse` made of it - and
|
|
87
|
+
* `String()` throws on `{"toString": 1}`. Thrown between ending the trace and
|
|
88
|
+
* plucking it, that left the trace registered for the life of the process.
|
|
89
|
+
*/
|
|
73
90
|
export function getUserIdSafely(callback, args, receiver, logger, transport) {
|
|
74
91
|
if (!callback) {
|
|
75
92
|
return undefined;
|
|
76
93
|
}
|
|
77
|
-
|
|
94
|
+
const name = `${transport}.getUserId`;
|
|
95
|
+
const outcome = "completing the trace without a user id";
|
|
96
|
+
const userId = invokeUserCallbackSafely(callback, args, receiver, () => undefined, logger, name, outcome);
|
|
97
|
+
if (userId === undefined || typeof userId === "string") {
|
|
98
|
+
return userId;
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
// oxlint-disable-next-line typescript/no-base-to-string -- recorded as `String()` always recorded it
|
|
102
|
+
return String(userId);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
reportCallbackFailure(callback, logger, name, "returned a value that cannot be made a string", outcome, error);
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
78
108
|
}
|
|
79
109
|
/**
|
|
80
110
|
* Completes a trace once its operation has ended, without ever leaking a
|
|
@@ -14,12 +14,19 @@ interface GqlRequestStartContext {
|
|
|
14
14
|
}
|
|
15
15
|
interface GqlRequestEndContext extends GqlRequestStartContext {
|
|
16
16
|
/** `GraphQLError`s, structurally: the `graphql` package is an optional peer. */
|
|
17
|
-
errors?: readonly
|
|
18
|
-
message?: string;
|
|
19
|
-
originalError?: unknown;
|
|
20
|
-
}[];
|
|
17
|
+
errors?: readonly GqlError[];
|
|
21
18
|
state?: unknown;
|
|
22
19
|
}
|
|
20
|
+
/** A `GraphQLError`, as much of it as is read here. */
|
|
21
|
+
interface GqlError {
|
|
22
|
+
message?: string;
|
|
23
|
+
originalError?: unknown;
|
|
24
|
+
/** Where in the response it belongs; absent before execution begins. */
|
|
25
|
+
path?: unknown;
|
|
26
|
+
extensions?: {
|
|
27
|
+
code?: unknown;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
23
30
|
/**
|
|
24
31
|
* What the start hook hands the end hook. Everything needed to close the
|
|
25
32
|
* operation travels in here rather than in a map keyed by trace id, because an
|
|
@@ -37,6 +44,8 @@ interface OperationState {
|
|
|
37
44
|
/** Whether this service opened the trace, and therefore has to ship it. */
|
|
38
45
|
ownsTrace: boolean;
|
|
39
46
|
context: unknown;
|
|
47
|
+
/** Closed already: refused by the application's start hook. */
|
|
48
|
+
ended?: boolean;
|
|
40
49
|
}
|
|
41
50
|
/**
|
|
42
51
|
* GraphQL operation instrumentation.
|
|
@@ -53,7 +62,8 @@ interface OperationState {
|
|
|
53
62
|
* document is processed, `setOnRequestEndHook` once it has been, right before
|
|
54
63
|
* the response goes out. Whatever the start hook returns is handed back as
|
|
55
64
|
* `state`, which is what lets one span be opened in the first and closed in the
|
|
56
|
-
* second. This service
|
|
65
|
+
* second. This service uses both and gives each operation a span, beside any
|
|
66
|
+
* hooks the application sets there - see `composeStartHook`.
|
|
57
67
|
*
|
|
58
68
|
* The span goes into the trace the HTTP agent already opened whenever there is
|
|
59
69
|
* one, which keeps the shape a reader expects: one snapshot per HTTP request,
|
|
@@ -90,6 +100,22 @@ export declare class GraphQLObserveAgentService<Store extends Record<string, unk
|
|
|
90
100
|
constructor(asyncLocalStorage: AsyncLocalStorage<Map<KeyOf<Store>, any>>, options: ObserveModuleOptionsWithDefaults, operationTraceRegistry: OperationTraceRegistry, observeAgentSharedBuffer: ObserveAgentSharedBuffer, traceSamplerService: TraceSamplerService, moduleRef: ModuleRef, discoveryService: DiscoveryService, metadataScanner: MetadataScanner);
|
|
91
101
|
onModuleInit(): Promise<void>;
|
|
92
102
|
registerRequestHooksIfPossible(): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* The start hook the host is given: this service's part first, so the span
|
|
105
|
+
* covers the application's hook, then the application's, whose result is
|
|
106
|
+
* kept for its own end hook.
|
|
107
|
+
*
|
|
108
|
+
* An application's start hook that throws refuses the document: the driver
|
|
109
|
+
* answers with the error and calls no end hook. The span is closed here
|
|
110
|
+
* then, with the application's error, so the refusal is recorded as a
|
|
111
|
+
* failed operation. A start hook that returns a promise gets one back, and
|
|
112
|
+
* only then - a driver that awaits the hook awaits it, and one that does
|
|
113
|
+
* not hands it to the end hook as the state, which is why the pair is also
|
|
114
|
+
* kept on the promise itself. Its rejection closes the span the same way,
|
|
115
|
+
* and travels on in the promise returned, to a driver that awaits it.
|
|
116
|
+
*/
|
|
117
|
+
private composeStartHook;
|
|
118
|
+
private closeRefused;
|
|
93
119
|
/**
|
|
94
120
|
* Opens a span for the operation about to be processed.
|
|
95
121
|
*
|
|
@@ -116,6 +142,8 @@ export declare class GraphQLObserveAgentService<Store extends Record<string, unk
|
|
|
116
142
|
* its status code and no spans under it.
|
|
117
143
|
*/
|
|
118
144
|
onRequestEnd(ctx: GqlRequestEndContext): void;
|
|
145
|
+
/** Closes the operation's span once, and ships a trace this service opened. */
|
|
146
|
+
private endOperation;
|
|
119
147
|
/**
|
|
120
148
|
* The common case: the operation arrived over an HTTP request the HTTP agent
|
|
121
149
|
* already opened a trace for. The operation becomes a root span in that trace
|
|
@@ -170,6 +198,9 @@ export declare class GraphQLObserveAgentService<Store extends Record<string, unk
|
|
|
170
198
|
* `GraphQLError` wrapping it, because that is the error the registry
|
|
171
199
|
* classifies: an `IntrinsicException` a handler raised on purpose reads as
|
|
172
200
|
* handled, and it stops being recognisable once GraphQL has wrapped it.
|
|
201
|
+
*
|
|
202
|
+
* An error graphql refused the request with is recorded by its class and
|
|
203
|
+
* code alone - see `toRefusal`.
|
|
173
204
|
*/
|
|
174
205
|
private toSpanError;
|
|
175
206
|
private lookupResolverHandler;
|
|
@@ -18,8 +18,10 @@ import { ObserveAgentSharedBuffer } from "../agent/observe-agent.shared-buffer.j
|
|
|
18
18
|
import { CALLER_METADATA_KEY, OBSERVE_OPTIONS, TRACE_REGISTRY_KEY, } from "../observe.constants.js";
|
|
19
19
|
import { OperationTraceRegistry } from "../services/operation-trace.registry.js";
|
|
20
20
|
import { TraceSamplerService } from "../services/trace-sampler.service.js";
|
|
21
|
+
import { setAgentHook } from "../utils/shared-hook-slot.util.js";
|
|
21
22
|
import { parseGraphQLOperation, toResolveInfoLike, } from "./graphql-operation-parser.js";
|
|
22
23
|
import { deferTraceCompletion, generateTraceIdSafely, getUserIdSafely, setAttributesSafely, shouldIgnoreSafely, } from "./deferred-trace-completion.js";
|
|
24
|
+
import { endOperation, OPERATION_STATE_KEY, openOperation, } from "../utils/operation-state.util.js";
|
|
23
25
|
/**
|
|
24
26
|
* Protocol recorded for a GraphQL operation that arrived over something other
|
|
25
27
|
* than an instrumented HTTP request. A query over HTTP keeps `http` as its
|
|
@@ -36,6 +38,12 @@ const GRAPHQL_PROTOCOL = "graphql";
|
|
|
36
38
|
const RESOLVER_TYPE_METADATA = "graphql:resolver_type";
|
|
37
39
|
const RESOLVER_NAME_METADATA = "graphql:resolver_name";
|
|
38
40
|
const ROOT_TYPE_NAMES = new Set(["Query", "Mutation", "Subscription"]);
|
|
41
|
+
/**
|
|
42
|
+
* Where the start hook the host is given keeps both sides' state, on what it
|
|
43
|
+
* returns: this service's, and whatever the application's own start hook
|
|
44
|
+
* returned, each handed back to the end hook it belongs to.
|
|
45
|
+
*/
|
|
46
|
+
const SHARED_STATE = Symbol("nestjs.observe.graphqlRequestState");
|
|
39
47
|
/**
|
|
40
48
|
* GraphQL operation instrumentation.
|
|
41
49
|
*
|
|
@@ -51,7 +59,8 @@ const ROOT_TYPE_NAMES = new Set(["Query", "Mutation", "Subscription"]);
|
|
|
51
59
|
* document is processed, `setOnRequestEndHook` once it has been, right before
|
|
52
60
|
* the response goes out. Whatever the start hook returns is handed back as
|
|
53
61
|
* `state`, which is what lets one span be opened in the first and closed in the
|
|
54
|
-
* second. This service
|
|
62
|
+
* second. This service uses both and gives each operation a span, beside any
|
|
63
|
+
* hooks the application sets there - see `composeStartHook`.
|
|
55
64
|
*
|
|
56
65
|
* The span goes into the trace the HTTP agent already opened whenever there is
|
|
57
66
|
* one, which keeps the shape a reader expects: one snapshot per HTTP request,
|
|
@@ -147,10 +156,69 @@ let GraphQLObserveAgentService = GraphQLObserveAgentService_1 = class GraphQLObs
|
|
|
147
156
|
this.logger.warn("The installed version of @nestjs/graphql does not expose the GraphQL request lifecycle hooks ('setOnRequestStartHook' / 'setOnRequestEndHook'), so GraphQL operations cannot be instrumented. Upgrade @nestjs/graphql to collect per-operation traces.");
|
|
148
157
|
return;
|
|
149
158
|
}
|
|
150
|
-
|
|
151
|
-
|
|
159
|
+
if (this.isPatched) {
|
|
160
|
+
// The other attempt landed while this one waited for the import.
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
// The host's hooks are public API, and the application's to set as well:
|
|
164
|
+
// a check that refuses a document by throwing from the start hook, an
|
|
165
|
+
// audit record written in the end hook. Shared, so neither replaces the
|
|
166
|
+
// other, whichever is set first. The getters hand the application its own
|
|
167
|
+
// hooks - Nest calls the hooks through `onRequestStart` and
|
|
168
|
+
// `onRequestEnd`, never through them.
|
|
169
|
+
setAgentHook(host, "setOnRequestStartHook", (ctx) => this.onRequestStart(ctx), (application, agent) => this.composeStartHook(application, agent), { getter: "getOnRequestStartHook", repointGetter: true });
|
|
170
|
+
setAgentHook(host, "setOnRequestEndHook", (ctx) => this.onRequestEnd(ctx), composeEndHook, { getter: "getOnRequestEndHook", repointGetter: true });
|
|
152
171
|
this.isPatched = true;
|
|
153
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* The start hook the host is given: this service's part first, so the span
|
|
175
|
+
* covers the application's hook, then the application's, whose result is
|
|
176
|
+
* kept for its own end hook.
|
|
177
|
+
*
|
|
178
|
+
* An application's start hook that throws refuses the document: the driver
|
|
179
|
+
* answers with the error and calls no end hook. The span is closed here
|
|
180
|
+
* then, with the application's error, so the refusal is recorded as a
|
|
181
|
+
* failed operation. A start hook that returns a promise gets one back, and
|
|
182
|
+
* only then - a driver that awaits the hook awaits it, and one that does
|
|
183
|
+
* not hands it to the end hook as the state, which is why the pair is also
|
|
184
|
+
* kept on the promise itself. Its rejection closes the span the same way,
|
|
185
|
+
* and travels on in the promise returned, to a driver that awaits it.
|
|
186
|
+
*/
|
|
187
|
+
composeStartHook(application, agent) {
|
|
188
|
+
const refuse = (state, error) => this.closeRefused(state, error);
|
|
189
|
+
return function (ctx) {
|
|
190
|
+
const observe = agent.call(this, ctx);
|
|
191
|
+
let returned;
|
|
192
|
+
try {
|
|
193
|
+
returned = application?.call(this, ctx);
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
refuse(observe, error);
|
|
197
|
+
throw error;
|
|
198
|
+
}
|
|
199
|
+
if (!isThenable(returned)) {
|
|
200
|
+
return toSharedState({ observe, application: returned });
|
|
201
|
+
}
|
|
202
|
+
const settled = Promise.resolve(returned).then((value) => toSharedState({ observe, application: value }), (error) => {
|
|
203
|
+
refuse(observe, error);
|
|
204
|
+
throw error;
|
|
205
|
+
});
|
|
206
|
+
// Handled here, as a driver that does not await it never does: its
|
|
207
|
+
// rejection would otherwise be one only the agent made, beside the
|
|
208
|
+
// application's own promise, which the application may well handle.
|
|
209
|
+
// A driver that awaits it still sees the rejection.
|
|
210
|
+
settled.catch(() => undefined);
|
|
211
|
+
return Object.defineProperty(settled, SHARED_STATE, {
|
|
212
|
+
value: { observe, application: returned },
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
closeRefused(state, error) {
|
|
217
|
+
if (!state) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
this.endOperation(state, error ?? new Error("Refused by a GraphQL request start hook"));
|
|
221
|
+
}
|
|
154
222
|
/**
|
|
155
223
|
* Opens a span for the operation about to be processed.
|
|
156
224
|
*
|
|
@@ -213,6 +281,14 @@ let GraphQLObserveAgentService = GraphQLObserveAgentService_1 = class GraphQLObs
|
|
|
213
281
|
if (!state) {
|
|
214
282
|
return;
|
|
215
283
|
}
|
|
284
|
+
this.endOperation(state, this.toSpanError(ctx.errors));
|
|
285
|
+
}
|
|
286
|
+
/** Closes the operation's span once, and ships a trace this service opened. */
|
|
287
|
+
endOperation(state, error) {
|
|
288
|
+
if (state.ended) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
state.ended = true;
|
|
216
292
|
if (state.store) {
|
|
217
293
|
// Handing the request back whatever owned it before this operation. The
|
|
218
294
|
// store is shared by reference across the request, so this is a real
|
|
@@ -224,8 +300,9 @@ let GraphQLObserveAgentService = GraphQLObserveAgentService_1 = class GraphQLObs
|
|
|
224
300
|
state.store.set(CALLER_METADATA_KEY, state.previousCallerId);
|
|
225
301
|
}
|
|
226
302
|
}
|
|
227
|
-
this.operationTraceRegistry.internalEndTraceStep(state.traceId, `${state.className}#${state.methodKey}`, state.className, state.methodKey, state.spanId,
|
|
303
|
+
this.operationTraceRegistry.internalEndTraceStep(state.traceId, `${state.className}#${state.methodKey}`, state.className, state.methodKey, state.spanId, error);
|
|
228
304
|
if (state.ownsTrace) {
|
|
305
|
+
endOperation(state.store?.get(OPERATION_STATE_KEY));
|
|
229
306
|
this.endOperationTrace(state.traceId, state.context);
|
|
230
307
|
}
|
|
231
308
|
}
|
|
@@ -277,6 +354,8 @@ let GraphQLObserveAgentService = GraphQLObserveAgentService_1 = class GraphQLObs
|
|
|
277
354
|
const traceId = generateTraceIdSafely(this.options.traceIdGenerator, info, this.options, this.logger);
|
|
278
355
|
const store = new Map();
|
|
279
356
|
store.set(this.options.traceIdKey, traceId);
|
|
357
|
+
// Ended with the operation's trace: see `liveTraceId`.
|
|
358
|
+
openOperation(store);
|
|
280
359
|
this.asyncLocalStorage.enterWith(store);
|
|
281
360
|
this.applyAttributes(info, ctx.context);
|
|
282
361
|
this.operationTraceRegistry.startTrace(traceId, {
|
|
@@ -348,13 +427,24 @@ let GraphQLObserveAgentService = GraphQLObserveAgentService_1 = class GraphQLObs
|
|
|
348
427
|
* `GraphQLError` wrapping it, because that is the error the registry
|
|
349
428
|
* classifies: an `IntrinsicException` a handler raised on purpose reads as
|
|
350
429
|
* handled, and it stops being recognisable once GraphQL has wrapped it.
|
|
430
|
+
*
|
|
431
|
+
* An error graphql refused the request with is recorded by its class and
|
|
432
|
+
* code alone - see `toRefusal`.
|
|
351
433
|
*/
|
|
352
434
|
toSpanError(errors) {
|
|
353
435
|
const [first] = errors ?? [];
|
|
354
436
|
if (!first) {
|
|
355
437
|
return undefined;
|
|
356
438
|
}
|
|
357
|
-
|
|
439
|
+
const original = first.originalError;
|
|
440
|
+
const error = original ?? first;
|
|
441
|
+
// No path: raised by parsing, validation or the coercion of variables,
|
|
442
|
+
// before any resolver ran. A path, and an original error pointing at
|
|
443
|
+
// syntax of its own: an argument refused as its field was executed. A
|
|
444
|
+
// resolver's own error points at none.
|
|
445
|
+
return first.path == null || original?.nodes != null
|
|
446
|
+
? toRefusal(first, error)
|
|
447
|
+
: error;
|
|
358
448
|
}
|
|
359
449
|
lookupResolverHandler(rootTypeName, fieldName) {
|
|
360
450
|
this.resolverIndex ??= this.buildResolverIndex();
|
|
@@ -423,3 +513,74 @@ GraphQLObserveAgentService = GraphQLObserveAgentService_1 = __decorate([
|
|
|
423
513
|
MetadataScanner])
|
|
424
514
|
], GraphQLObserveAgentService);
|
|
425
515
|
export { GraphQLObserveAgentService };
|
|
516
|
+
/**
|
|
517
|
+
* The end hook the host is given: the application's first, with what its own
|
|
518
|
+
* start hook returned, then this service's, whatever the application's did,
|
|
519
|
+
* so the span covers both and is closed either way.
|
|
520
|
+
*/
|
|
521
|
+
function composeEndHook(application, agent) {
|
|
522
|
+
return function (ctx) {
|
|
523
|
+
const shared = readSharedState(ctx.state);
|
|
524
|
+
try {
|
|
525
|
+
application?.call(this, shared ? { ...ctx, state: shared.application } : ctx);
|
|
526
|
+
}
|
|
527
|
+
finally {
|
|
528
|
+
agent.call(this, { ...ctx, state: shared?.observe });
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
function toSharedState(shared) {
|
|
533
|
+
return { [SHARED_STATE]: shared };
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* The pair the start hook kept, from its result as the driver hands it on:
|
|
537
|
+
* the object it returned, the promise it returned to a driver that does not
|
|
538
|
+
* await it, or what that promise resolved to for one that does. Nothing for
|
|
539
|
+
* a state no start hook of ours produced.
|
|
540
|
+
*/
|
|
541
|
+
function readSharedState(state) {
|
|
542
|
+
return typeof state === "object" && state !== null
|
|
543
|
+
? state[SHARED_STATE]
|
|
544
|
+
: undefined;
|
|
545
|
+
}
|
|
546
|
+
function isThenable(value) {
|
|
547
|
+
return ((typeof value === "object" || typeof value === "function") &&
|
|
548
|
+
value !== null &&
|
|
549
|
+
typeof value.then === "function");
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* What a request graphql refused is recorded with: the error's class and its
|
|
553
|
+
* code, `GRAPHQL_VALIDATION_FAILED` or `BAD_USER_INPUT`, and nothing graphql
|
|
554
|
+
* worded. graphql words these errors around the value it refused - `String
|
|
555
|
+
* cannot represent a non string value: 489213`, `found String "..."` - which
|
|
556
|
+
* the recorded document shows blanked, and which no rule can blank in prose:
|
|
557
|
+
* a string is printed there unescaped. The stack is the message again, then
|
|
558
|
+
* frames of graphql and the server, not of the application.
|
|
559
|
+
*/
|
|
560
|
+
function toRefusal(first, error) {
|
|
561
|
+
const code = first.extensions?.code ??
|
|
562
|
+
error.extensions?.code;
|
|
563
|
+
const message = typeof code === "string" && /^[A-Z][A-Z0-9_]*$/.test(code)
|
|
564
|
+
? code
|
|
565
|
+
: "GraphQL request error";
|
|
566
|
+
const refusal = error instanceof Error
|
|
567
|
+
? Object.create(Object.getPrototypeOf(error))
|
|
568
|
+
: new Error();
|
|
569
|
+
const name = error.constructor
|
|
570
|
+
?.name;
|
|
571
|
+
// What the registry classifies a failure by: its class, kept above, and
|
|
572
|
+
// the status an `HttpException` thrown by a custom scalar answers with.
|
|
573
|
+
const status = error.status;
|
|
574
|
+
if (typeof status === "number") {
|
|
575
|
+
Object.defineProperty(refusal, "status", { value: status });
|
|
576
|
+
}
|
|
577
|
+
Object.defineProperties(refusal, {
|
|
578
|
+
message: { value: message, configurable: true, writable: true },
|
|
579
|
+
stack: {
|
|
580
|
+
value: `${typeof name === "string" && name ? name : "Error"}: ${message}`,
|
|
581
|
+
configurable: true,
|
|
582
|
+
writable: true,
|
|
583
|
+
},
|
|
584
|
+
});
|
|
585
|
+
return refusal;
|
|
586
|
+
}
|