@timber-js/app 0.1.45 → 0.1.47

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.
@@ -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
  };
@@ -906,6 +916,7 @@ function createPipeline(config) {
906
916
  }
907
917
  const responseHeaders = new Headers();
908
918
  const requestHeaderOverlay = new Headers();
919
+ responseHeaders.set("Cache-Control", "private, no-cache, no-store, max-age=0, must-revalidate");
909
920
  if (earlyHints) try {
910
921
  await earlyHints(match, req, responseHeaders);
911
922
  } catch {}
@@ -977,6 +988,14 @@ function createPipeline(config) {
977
988
  markResponseFlushed();
978
989
  return response;
979
990
  } catch (error) {
991
+ if (error instanceof DenySignal) return new Response(null, { status: error.status });
992
+ if (error instanceof RedirectSignal) {
993
+ responseHeaders.set("Location", error.location);
994
+ return new Response(null, {
995
+ status: error.status,
996
+ headers: responseHeaders
997
+ });
998
+ }
980
999
  logRenderError({
981
1000
  method,
982
1001
  path,