@timber-js/app 0.1.45 → 0.1.46
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/dist/server/index.js
CHANGED
|
@@ -787,11 +787,13 @@ function pathnameMatchesPattern(pathname, pattern) {
|
|
|
787
787
|
*/
|
|
788
788
|
function createPipeline(config) {
|
|
789
789
|
const { proxy, matchRoute, render, earlyHints, stripTrailingSlash = true, slowRequestMs = 3e3, enableServerTiming = false, onPipelineError } = config;
|
|
790
|
+
let activeRequests = 0;
|
|
790
791
|
return async (req) => {
|
|
791
792
|
const url = new URL(req.url);
|
|
792
793
|
const method = req.method;
|
|
793
794
|
const path = url.pathname;
|
|
794
795
|
const startTime = performance.now();
|
|
796
|
+
activeRequests++;
|
|
795
797
|
return runWithTraceId(generateTraceId(), async () => {
|
|
796
798
|
return runWithRequestContext(req, async () => {
|
|
797
799
|
const runRequest = async () => {
|
|
@@ -815,22 +817,30 @@ function createPipeline(config) {
|
|
|
815
817
|
result = ensureMutableResponse(result);
|
|
816
818
|
result.headers.set("Server-Timing", serverTiming);
|
|
817
819
|
}
|
|
820
|
+
} else {
|
|
821
|
+
const totalMs = Math.round(performance.now() - startTime);
|
|
822
|
+
result = ensureMutableResponse(result);
|
|
823
|
+
result.headers.set("Server-Timing", `total;dur=${totalMs}`);
|
|
818
824
|
}
|
|
819
825
|
return result;
|
|
820
826
|
});
|
|
821
827
|
const durationMs = Math.round(performance.now() - startTime);
|
|
822
828
|
const status = response.status;
|
|
829
|
+
const concurrency = activeRequests;
|
|
830
|
+
activeRequests--;
|
|
823
831
|
logRequestCompleted({
|
|
824
832
|
method,
|
|
825
833
|
path,
|
|
826
834
|
status,
|
|
827
|
-
durationMs
|
|
835
|
+
durationMs,
|
|
836
|
+
concurrency
|
|
828
837
|
});
|
|
829
838
|
if (slowRequestMs > 0 && durationMs > slowRequestMs) logSlowRequest({
|
|
830
839
|
method,
|
|
831
840
|
path,
|
|
832
841
|
durationMs,
|
|
833
|
-
threshold: slowRequestMs
|
|
842
|
+
threshold: slowRequestMs,
|
|
843
|
+
concurrency
|
|
834
844
|
});
|
|
835
845
|
return response;
|
|
836
846
|
};
|
|
@@ -977,6 +987,14 @@ function createPipeline(config) {
|
|
|
977
987
|
markResponseFlushed();
|
|
978
988
|
return response;
|
|
979
989
|
} catch (error) {
|
|
990
|
+
if (error instanceof DenySignal) return new Response(null, { status: error.status });
|
|
991
|
+
if (error instanceof RedirectSignal) {
|
|
992
|
+
responseHeaders.set("Location", error.location);
|
|
993
|
+
return new Response(null, {
|
|
994
|
+
status: error.status,
|
|
995
|
+
headers: responseHeaders
|
|
996
|
+
});
|
|
997
|
+
}
|
|
980
998
|
logRenderError({
|
|
981
999
|
method,
|
|
982
1000
|
path,
|