@m1212e/rumble 0.23.18 → 0.23.19
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/out/index.cjs +31 -7
- package/out/index.cjs.map +1 -1
- package/out/index.d.cts.map +1 -1
- package/out/index.d.mts.map +1 -1
- package/out/index.mjs +31 -7
- package/out/index.mjs.map +1 -1
- package/package.json +1 -1
package/out/index.mjs
CHANGED
|
@@ -182,7 +182,7 @@ function mapNullFieldsToUndefined(obj) {
|
|
|
182
182
|
}
|
|
183
183
|
//#endregion
|
|
184
184
|
//#region package.json
|
|
185
|
-
var version = "0.23.
|
|
185
|
+
var version = "0.23.19";
|
|
186
186
|
//#endregion
|
|
187
187
|
//#region lib/helpers/errorLogging.ts
|
|
188
188
|
function hasMessage(error) {
|
|
@@ -563,6 +563,24 @@ function recordSpanErrors(span, errors) {
|
|
|
563
563
|
function recordSpanError(span, error) {
|
|
564
564
|
recordSpanErrors(span, [error]);
|
|
565
565
|
}
|
|
566
|
+
/**
|
|
567
|
+
* Errors the operation wrapper has already reported.
|
|
568
|
+
*
|
|
569
|
+
* A transport can see the same failure twice: sofa, for instance, hands
|
|
570
|
+
* `result.errors` to its error handler *after* execute has returned, so without
|
|
571
|
+
* this the very same error would produce two log lines and two exception events,
|
|
572
|
+
* which quietly doubles error counts in dashboards. A WeakSet keeps this free of
|
|
573
|
+
* bookkeeping — entries disappear with the errors themselves.
|
|
574
|
+
*/
|
|
575
|
+
const reportedErrors = /* @__PURE__ */ new WeakSet();
|
|
576
|
+
function markErrorsReported(errors) {
|
|
577
|
+
for (const error of errors) if (typeof error === "object" && error !== null) reportedErrors.add(error);
|
|
578
|
+
}
|
|
579
|
+
/** True when every error was already reported by the operation wrapper. */
|
|
580
|
+
function errorsAlreadyReported(errors) {
|
|
581
|
+
if (errors.length === 0) return false;
|
|
582
|
+
return errors.every((error) => typeof error === "object" && error !== null && reportedErrors.has(error));
|
|
583
|
+
}
|
|
566
584
|
function safeJsonStringify(value) {
|
|
567
585
|
try {
|
|
568
586
|
return JSON.stringify(value, (_key, inner) => typeof inner === "bigint" ? inner.toString() : inner) ?? "null";
|
|
@@ -1603,6 +1621,7 @@ function buildTracedExecute(executeFn, rumbleInput, transport) {
|
|
|
1603
1621
|
...errorsLogField(result.errors)
|
|
1604
1622
|
}, "graphql execute completed with errors");
|
|
1605
1623
|
recordSpanErrors(span, result.errors);
|
|
1624
|
+
markErrorsReported(result.errors);
|
|
1606
1625
|
} else log?.info({
|
|
1607
1626
|
...telemetry.logFields,
|
|
1608
1627
|
[FIELD_DURATION_MS]: durationMs(start)
|
|
@@ -1615,6 +1634,7 @@ function buildTracedExecute(executeFn, rumbleInput, transport) {
|
|
|
1615
1634
|
...errorLogField(error)
|
|
1616
1635
|
}, "graphql execute threw");
|
|
1617
1636
|
recordSpanError(span, error);
|
|
1637
|
+
markErrorsReported([error]);
|
|
1618
1638
|
throw error;
|
|
1619
1639
|
}
|
|
1620
1640
|
};
|
|
@@ -1656,6 +1676,7 @@ function buildTracedSubscribe(subscribeFn, rumbleInput, transport) {
|
|
|
1656
1676
|
...errorsLogField(execResult.errors)
|
|
1657
1677
|
}, "graphql subscribe completed with errors");
|
|
1658
1678
|
recordSpanErrors(span, execResult.errors);
|
|
1679
|
+
markErrorsReported(execResult.errors);
|
|
1659
1680
|
}
|
|
1660
1681
|
return execResult;
|
|
1661
1682
|
}
|
|
@@ -1677,6 +1698,7 @@ function buildTracedSubscribe(subscribeFn, rumbleInput, transport) {
|
|
|
1677
1698
|
...errorLogField(error)
|
|
1678
1699
|
}, "graphql subscribe threw");
|
|
1679
1700
|
recordSpanError(span, error);
|
|
1701
|
+
markErrorsReported([error]);
|
|
1680
1702
|
throw error;
|
|
1681
1703
|
}
|
|
1682
1704
|
};
|
|
@@ -2841,12 +2863,14 @@ export const r = rumble({
|
|
|
2841
2863
|
execute: buildTracedExecute(args.execute ?? defaultExecute, rumbleInput, "rest"),
|
|
2842
2864
|
subscribe: buildTracedSubscribe(args.subscribe ?? defaultSubscribe, rumbleInput, "rest"),
|
|
2843
2865
|
errorHandler(errors) {
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2866
|
+
if (!errorsAlreadyReported(errors)) {
|
|
2867
|
+
recordSpanErrors(trace.getActiveSpan(), errors);
|
|
2868
|
+
telemetryLogger(rumbleInput)?.error({
|
|
2869
|
+
[ATTR_TRANSPORT]: "rest",
|
|
2870
|
+
...traceCorrelationFields(rumbleInput),
|
|
2871
|
+
...errorsLogField(errors)
|
|
2872
|
+
}, "rest request failed");
|
|
2873
|
+
}
|
|
2850
2874
|
return userErrorHandler?.(errors) ?? sofaErrorResponse(errors);
|
|
2851
2875
|
}
|
|
2852
2876
|
});
|