core: Async local storage doesn't work with debuggers
Package version
5.8.0
Node.js and npm version
Node: v18.6.0, NPM: 8.13.2
Sample Code (to reproduce the issue)
// config/app.ts
export const http = {
// other config
useAsyncLocalStorage: true,
}
// app/Services/MyService.ts
import HttpContext from '@ioc:Adonis/Core/HttpContext'
export default class MyService {
public myFunction() {
const context = HttpContext.get()
console.log(context)
}
}
It works fine when run normally. However context
is null if I try to run it with yarn debug
, vscode, or webstorm.
VSCode launch config
{
"type": "node",
"request": "launch",
"name": "Debug Backend",
"runtimeExecutable": "node",
"runtimeArgs": ["ace", "serve", "--watch"],
"internalConsoleOptions": "openOnSessionStart",
"skipFiles": ["<node_internals>/**", "${workspaceRoot}/node_modules/**/*"]
}
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 21 (9 by maintainers)
Yup, I can confirm the issue still exists. Have to decouple it from AdonisJS and see if it still exists and then report it with Node