File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed
packages/kit/src/runtime/app/server Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @sveltejs/kit ' : patch
3
+ ---
4
+
5
+ fix: avoid using top-level await
Original file line number Diff line number Diff line change @@ -6,14 +6,13 @@ let request_event = null;
6
6
/** @type {import('node:async_hooks').AsyncLocalStorage<RequestEvent | null> } */
7
7
let als ;
8
8
9
- try {
10
- const hooks = await import ( 'node:async_hooks' ) ;
11
- als = new hooks . AsyncLocalStorage ( ) ;
12
- } catch {
13
- // can't use AsyncLocalStorage, but can still call getRequestEvent synchronously.
14
- // this isn't behind `supports` because it's basically just StackBlitz (i.e.
15
- // in-browser usage) that doesn't support it AFAICT
16
- }
9
+ import ( 'node:async_hooks' )
10
+ . then ( ( hooks ) => ( als = new hooks . AsyncLocalStorage ( ) ) )
11
+ . catch ( ( ) => {
12
+ // can't use AsyncLocalStorage, but can still call getRequestEvent synchronously.
13
+ // this isn't behind `supports` because it's basically just StackBlitz (i.e.
14
+ // in-browser usage) that doesn't support it AFAICT
15
+ } ) ;
17
16
18
17
/**
19
18
* Returns the current `RequestEvent`. Can be used inside `handle`, `load` and actions (and functions called by them).
You can’t perform that action at this time.
0 commit comments