(handlerTarget, handlerThisArg, handlerArgs: unknown)
| 14 | export function patchEventHandler<H3EventHandler extends Function>(handler: H3EventHandler): H3EventHandler { |
| 15 | return new Proxy(handler, { |
| 16 | async apply(handlerTarget, handlerThisArg, handlerArgs: unknown) { |
| 17 | const isolationScope = getIsolationScope(); |
| 18 | const newIsolationScope = isolationScope === getDefaultIsolationScope() ? isolationScope.clone() : isolationScope; |
| 19 | |
| 20 | debug.log( |
| 21 | `Patched h3 event handler. ${ |
| 22 | isolationScope === newIsolationScope ? 'Using existing' : 'Created new' |
| 23 | } isolation scope.`, |
| 24 | ); |
| 25 | |
| 26 | return withIsolationScope(newIsolationScope, async () => { |
| 27 | try { |
| 28 | return await handlerTarget.apply(handlerThisArg, handlerArgs); |
| 29 | } finally { |
| 30 | await flushIfServerless(); |
| 31 | } |
| 32 | }); |
| 33 | }, |
| 34 | }); |
| 35 | } |
nothing calls this directly
no test coverage detected