DTK0021: AsyncLocalStorage Not Set
Package:
@vitejs/devtools
Message
AsyncLocalStorage is not set, it likely to be an internal bug of Vite DevTools
Cause
The RpcFunctionsHost.getCurrentRpcSession() method was called, but the internal AsyncLocalStorage instance used to track the current RPC session was never initialized. This storage is set up during WebSocket server creation and should always be available when RPC handlers execute. If it is missing, something went wrong during the DevTools initialization process.
Example
This error cannot be triggered by user code under normal circumstances. It would only occur if the internal wiring between the WebSocket server and the RPC host is broken.
export default defineDevToolsPlugin({
name: 'my-plugin',
setup(context) {
// This would throw DTK0021 only if the internal AsyncLocalStorage
// was never wired up (an internal bug)
const session = context.rpc.getCurrentRpcSession()
},
})Fix
This is an internal error in Vite DevTools. If you encounter it, please report it at https://github.com/vitejs/devtools/issues with:
- Your Vite DevTools version
- Steps to reproduce the issue
- Any relevant console output
Source
packages/core/src/node/host-functions.ts