core icon indicating copy to clipboard operation
core copied to clipboard

Async local storage doesn't work with debuggers

Open jaysson opened this issue 2 years ago • 0 comments

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/**/*"]
}

jaysson avatar Jul 23 '22 13:07 jaysson