File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 125
125
"vars" : {
126
126
// This is a bit misleading, but it means that we can have 500 concurrent revalidations
127
127
// This means that we'll have up to 100 durable objects instance running at the same time
128
- "MAX_REVALIDATE_CONCURRENCY" : " 100"
128
+ "MAX_REVALIDATE_CONCURRENCY" : " 100" ,
129
+ "OPEN_NEXT_REQUEST_ID_HEADER" : true
129
130
},
130
131
"r2_buckets" : [
131
132
{
Original file line number Diff line number Diff line change 153
153
// TODO: remove this once the issue is fixed
154
154
"DEBUG_CLOUDFLARE" : " true" ,
155
155
"WORKER_VERSION_ID" : " TO_REPLACE" ,
156
- "STAGE" : " production"
156
+ "STAGE" : " production" ,
157
+ "OPEN_NEXT_REQUEST_ID_HEADER" : true
157
158
},
158
159
"routes" : [
159
160
{
Original file line number Diff line number Diff line change 1
1
import { createLogger } from '@/lib/logger' ;
2
2
import { cache } from 'react' ;
3
3
4
+ const getRequestId = ( fallbackRequestId ?: string ) => {
5
+ // We are in OpenNext and we should have access to the request ID.
6
+ if ( ( globalThis as any ) . __openNextAls ) {
7
+ return ( globalThis as any ) . __openNextAls . getStore ( ) ?. requestId ;
8
+ }
9
+ return fallbackRequestId ;
10
+ } ;
11
+
4
12
// We don't want to use react cache in the edge runtime, so we use a different logger creation method.
5
13
// It is treeshaken by Next.js.
6
14
export const getLogger =
7
15
process . env . NEXT_RUNTIME === 'edge'
8
- ? ( ) => createLogger ( 'GBO' , { } )
16
+ ? ( ) =>
17
+ createLogger ( 'GBO' , {
18
+ requestId : getRequestId ( ) ,
19
+ } )
9
20
: cache ( ( ) => {
10
21
// This is not cryptographically secure, but it's fine for logging purposes.
11
22
// It allows us to identify logs from the same request.
12
- const requestId = Math . random ( ) . toString ( 36 ) . substring ( 2 , 15 ) ;
23
+ const requestId = getRequestId ( Math . random ( ) . toString ( 36 ) . substring ( 2 , 15 ) ) ;
13
24
return createLogger ( 'GBOV2' , { requestId } ) ;
14
25
} ) ;
You can’t perform that action at this time.
0 commit comments