fix Thread hot reloading
This commit is contained in:
parent
d8f7ed63cd
commit
66b4552def
|
|
@ -7,7 +7,9 @@ import { NOSE_SYS_BIN, NOSE_USR_BIN } from "./config"
|
||||||
import { isFile } from "./utils"
|
import { isFile } from "./utils"
|
||||||
import { AsyncLocalStorage } from "async_hooks"
|
import { AsyncLocalStorage } from "async_hooks"
|
||||||
|
|
||||||
export const Thread = new AsyncLocalStorage<State>()
|
// Ensure "Thread" lives between bun's hot reloads
|
||||||
|
const g = globalThis as typeof globalThis & { __thread?: AsyncLocalStorage<State> }
|
||||||
|
export const Thread = g.__thread ??= new AsyncLocalStorage<State>()
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
id?: string
|
id?: string
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user