Skip to content

Commit cbc95cc

Browse files
committed
relax request types
1 parent 5ccfc7c commit cbc95cc

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/cloudflare/src/request.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import type {
22
EventPluginContext,
33
ExecutionContext,
44
IncomingRequestCfProperties,
5-
Request,
6-
Response,
5+
Request as CloudflareRequest,
76
} from '@cloudflare/workers-types';
87
import {
98
captureException,
@@ -30,7 +29,7 @@ interface RequestHandlerWrapperOptions<
3029
PluginParams = any,
3130
> {
3231
options: CloudflareOptions;
33-
request: Request<unknown, IncomingRequestCfProperties<unknown>>;
32+
request: Request;
3433
context: ExecutionContext | EventPluginContext<Env, Params, Data, PluginParams>;
3534
}
3635

@@ -43,6 +42,7 @@ export function wrapRequestHandler(
4342
): Promise<Response> {
4443
return withIsolationScope(async isolationScope => {
4544
const { options, request } = wrapperOptions;
45+
const cloudflareRequest = request as unknown as CloudflareRequest<unknown, IncomingRequestCfProperties>;
4646

4747
// In certain situations, the passed context can become undefined.
4848
// For example, for Astro while prerendering pages at build time.
@@ -64,10 +64,10 @@ export function wrapRequestHandler(
6464

6565
addCloudResourceContext(isolationScope);
6666
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;
7171
}
7272
}
7373

0 commit comments

Comments
 (0)