Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a804fb6

Browse filesBrowse files
committed
clean up instrumentDurableObjectWithSentry generics
1 parent 3e08a52 commit a804fb6
Copy full SHA for a804fb6

File tree

Expand file treeCollapse file tree

1 file changed

+9
-8
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-8
lines changed

‎packages/cloudflare/src/durableobject.ts

Copy file name to clipboardExpand all lines: packages/cloudflare/src/durableobject.ts
+9-8Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.