Skip to content

Commit a804fb6

Browse files
committed
clean up instrumentDurableObjectWithSentry generics
1 parent 3e08a52 commit a804fb6

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

packages/cloudflare/src/durableobject.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,26 +125,27 @@ function wrapMethodWithSentry<T extends (...args: any[]) => any>(
125125
* }
126126
*
127127
* export const MyDurableObject = instrumentDurableObjectWithSentry(
128-
* env => ({
128+
* (env: Env) => ({
129129
* dsn: env.SENTRY_DSN,
130130
* tracesSampleRate: 1.0,
131131
* }),
132132
* MyDurableObjectBase,
133133
* );
134134
* ```
135135
*/
136-
export function instrumentDurableObjectWithSentry<
137-
E,
138-
T extends DurableObject & Rpc.DurableObjectBranded,
139-
C extends new (ctx: DurableObjectState, env: E) => T,
140-
>(optionsCallback: (env: E) => CloudflareOptions, DurableObjectClass: C): C {
141-
return new Proxy(DurableObjectClass, {
136+
export function instrumentDurableObjectWithSentry<E, C>(
137+
optionsCallback: (env: E) => CloudflareOptions,
138+
DurableObjectClass: C,
139+
): C {
140+
// We need to use `any` here because of type issues with the Durable Object constructor.
141+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
142+
return new Proxy(DurableObjectClass as any, {
142143
construct(target, [context, env]) {
143144
setAsyncLocalStorageAsyncContextStrategy();
144145

145146
const options = getFinalOptions(optionsCallback(env), env);
146147

147-
const obj = new target(context, env);
148+
const obj = new target(context, env) as DurableObject & Rpc.DurableObjectBranded;
148149

149150
// These are the methods that are available on a Durable Object
150151
// ref: https://developers.cloudflare.com/durable-objects/api/base/

0 commit comments

Comments
 (0)