()
| 21 | * @since 2.20.0 |
| 22 | */ |
| 23 | export function getRequestEvent() { |
| 24 | const event = request_event ?? als?.getStore(); |
| 25 | |
| 26 | if (!event) { |
| 27 | let message = |
| 28 | 'Can only read the current request event inside functions invoked during `handle`, such as server `load` functions, actions, endpoints, and other server hooks.'; |
| 29 | |
| 30 | if (!als) { |
| 31 | message += |
| 32 | ' In environments without `AsyncLocalStorage`, the event must be read synchronously, not after an `await`.'; |
| 33 | } |
| 34 | |
| 35 | throw new Error(message); |
| 36 | } |
| 37 | |
| 38 | return event; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * @template T |
no outgoing calls
no test coverage detected