@@ -22,7 +22,7 @@ type Env = Record<string, unknown>
2222
2323function instrumentBindingStub ( stub : DurableObjectStub , nsName : string ) : DurableObjectStub {
2424 const stubHandler : ProxyHandler < typeof stub > = {
25- get ( target , prop ) {
25+ get ( target , prop , receiver ) {
2626 if ( prop === 'fetch' ) {
2727 const fetcher = Reflect . get ( target , prop )
2828 const attrs = {
@@ -33,7 +33,7 @@ function instrumentBindingStub(stub: DurableObjectStub, nsName: string): Durable
3333 }
3434 return instrumentClientFetch ( fetcher , ( ) => ( { includeTraceContext : true } ) , attrs )
3535 } else {
36- return passthroughGet ( target , prop )
36+ return passthroughGet ( target , prop , receiver )
3737 }
3838 } ,
3939 }
@@ -52,12 +52,12 @@ function instrumentBindingGet(getFn: DurableObjectNamespace['get'], nsName: stri
5252
5353export function instrumentDOBinding ( ns : DurableObjectNamespace , nsName : string ) {
5454 const nsHandler : ProxyHandler < typeof ns > = {
55- get ( target , prop ) {
55+ get ( target , prop , receiver ) {
5656 if ( prop === 'get' ) {
57- const fn = Reflect . get ( ns , prop )
57+ const fn = Reflect . get ( ns , prop , receiver )
5858 return instrumentBindingGet ( fn , nsName )
5959 } else {
60- return passthroughGet ( target , prop )
60+ return passthroughGet ( target , prop , receiver )
6161 }
6262 } ,
6363 }
@@ -176,22 +176,23 @@ function instrumentAlarmFn(alarmFn: AlarmFn, initialiser: Initialiser, env: Env,
176176 return wrap ( alarmFn , alarmHandler )
177177}
178178
179- function instrumentAnyFn ( fn : ( ) => any , initialiser : Initialiser , env : Env , id : DurableObjectId ) {
179+ function instrumentAnyFn ( fn : ( ) => any , initialiser : Initialiser , env : Env , _id : DurableObjectId ) {
180180 if ( ! fn ) return undefined
181181
182- const alarmHandler : ProxyHandler < ( ) => any > = {
183- async apply ( target , thisArg ) {
182+ const fnHandler : ProxyHandler < ( ) => any > = {
183+ async apply ( target , thisArg , argArray : [ ] ) {
184+ thisArg = unwrap ( thisArg )
184185 const config = initialiser ( env , 'do-alarm' )
185186 const context = setConfig ( config )
186187 try {
187188 const bound = target . bind ( unwrap ( thisArg ) )
188- return await api_context . with ( context , executeDOAlarm , undefined , bound , id )
189+ return await api_context . with ( context , ( ) => bound . apply ( thisArg , argArray ) , undefined )
189190 } catch ( error ) {
190191 throw error
191192 }
192193 } ,
193194 }
194- return wrap ( fn , alarmHandler )
195+ return wrap ( fn , fnHandler )
195196}
196197
197198function instrumentDurableObject (
0 commit comments