@@ -2,8 +2,7 @@ import type {
2
2
EventPluginContext ,
3
3
ExecutionContext ,
4
4
IncomingRequestCfProperties ,
5
- Request ,
6
- Response ,
5
+ Request as CloudflareRequest ,
7
6
} from '@cloudflare/workers-types' ;
8
7
import {
9
8
captureException ,
@@ -30,7 +29,7 @@ interface RequestHandlerWrapperOptions<
30
29
PluginParams = any ,
31
30
> {
32
31
options : CloudflareOptions ;
33
- request : Request < unknown , IncomingRequestCfProperties < unknown > > ;
32
+ request : Request ;
34
33
context : ExecutionContext | EventPluginContext < Env , Params , Data , PluginParams > ;
35
34
}
36
35
@@ -43,6 +42,7 @@ export function wrapRequestHandler(
43
42
) : Promise < Response > {
44
43
return withIsolationScope ( async isolationScope => {
45
44
const { options, request } = wrapperOptions ;
45
+ const cloudflareRequest = request as unknown as CloudflareRequest < unknown , IncomingRequestCfProperties > ;
46
46
47
47
// In certain situations, the passed context can become undefined.
48
48
// For example, for Astro while prerendering pages at build time.
@@ -64,10 +64,10 @@ export function wrapRequestHandler(
64
64
65
65
addCloudResourceContext ( isolationScope ) ;
66
66
if ( request ) {
67
- addRequest ( isolationScope , request ) ;
68
- if ( request . cf ) {
69
- addCultureContext ( isolationScope , request . cf ) ;
70
- attributes [ 'network.protocol.name' ] = request . cf . httpProtocol ;
67
+ addRequest ( isolationScope , cloudflareRequest ) ;
68
+ if ( cloudflareRequest . cf ) {
69
+ addCultureContext ( isolationScope , cloudflareRequest . cf as IncomingRequestCfProperties ) ;
70
+ attributes [ 'network.protocol.name' ] = cloudflareRequest . cf . httpProtocol ;
71
71
}
72
72
}
73
73
0 commit comments