( request: NodeNextRequest, requestStartTime: bigint, requestEndTime: bigint, statusCode: number, devRequestTimingMiddlewareStart: bigint | undefined, devRequestTimingMiddlewareEnd: bigint | undefined, devRequestTimingInternalsEnd: bigint | undefined, devGenerateStaticParamsDuration: bigint | undefined )
| 82 | } |
| 83 | |
| 84 | function logIncomingRequests( |
| 85 | request: NodeNextRequest, |
| 86 | requestStartTime: bigint, |
| 87 | requestEndTime: bigint, |
| 88 | statusCode: number, |
| 89 | devRequestTimingMiddlewareStart: bigint | undefined, |
| 90 | devRequestTimingMiddlewareEnd: bigint | undefined, |
| 91 | devRequestTimingInternalsEnd: bigint | undefined, |
| 92 | devGenerateStaticParamsDuration: bigint | undefined |
| 93 | ): void { |
| 94 | const isRSC = getRequestMeta(request, 'isRSCRequest') |
| 95 | const url = isRSC ? stripNextRscUnionQuery(request.url) : request.url |
| 96 | |
| 97 | const statusCodeColor = |
| 98 | statusCode < 200 |
| 99 | ? white |
| 100 | : statusCode < 300 |
| 101 | ? green |
| 102 | : statusCode < 400 |
| 103 | ? blue |
| 104 | : statusCode < 500 |
| 105 | ? yellow |
| 106 | : red |
| 107 | |
| 108 | const coloredStatus = statusCodeColor(statusCode.toString()) |
| 109 | |
| 110 | const totalRequestTime = requestEndTime - requestStartTime |
| 111 | |
| 112 | const times: Array<[label: string, time: bigint]> = [] |
| 113 | |
| 114 | let middlewareTime: bigint | undefined |
| 115 | if (devRequestTimingMiddlewareStart && devRequestTimingMiddlewareEnd) { |
| 116 | middlewareTime = |
| 117 | devRequestTimingMiddlewareEnd - devRequestTimingMiddlewareStart |
| 118 | times.push(['proxy.ts', middlewareTime]) |
| 119 | } |
| 120 | |
| 121 | if (devRequestTimingInternalsEnd) { |
| 122 | let frameworkTime = devRequestTimingInternalsEnd - requestStartTime |
| 123 | |
| 124 | /* Middleware runs during the internals so we have to subtract it from the framework time */ |
| 125 | if (middlewareTime) { |
| 126 | frameworkTime -= middlewareTime |
| 127 | } |
| 128 | // Insert as the first item to be rendered in the list |
| 129 | times.unshift(['next.js', frameworkTime]) |
| 130 | |
| 131 | // Insert after compile, before render based on the execution order. |
| 132 | if (devGenerateStaticParamsDuration) { |
| 133 | // Pages Router getStaticPaths are technically "generate params" as well. |
| 134 | times.push(['generate-params', devGenerateStaticParamsDuration]) |
| 135 | } |
| 136 | |
| 137 | times.push([ |
| 138 | 'application-code', |
| 139 | requestEndTime - devRequestTimingInternalsEnd, |
| 140 | ]) |
| 141 | } |
no test coverage detected