Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vine library errors are not displaying if make useAsyncLocalStorage: true in config/app.js #4863

Closed
Adiconquerors opened this issue Jan 24, 2025 · 1 comment
Assignees
Labels
Type: Invalid Doesn't really belong here. Maybe use discussion threads?

Comments

@Adiconquerors
Copy link

Package version

Adonis Version: 6.17.0 and Vine Version: 3.0.0

Describe the bug

Vine library errors are not displaying if make
useAsyncLocalStorage: true
in config/app.js

If I make
useAsyncLocalStorage: false
Vine errors are displaying.

But my requirement is to use HttpContext in my helper file. To use this HttpContext in helper I have to make useAsyncLocalStorage: false

How to resolve this?

Here is my code snippet:

// start/helper.ts
export async function hasPermission(user: User, permission: string): Promise<boolean> {
  if (!user.id) {
    return false // Ensure the user is logged in
  }
  const ctx = HttpContext.getOrFail() // I want to use HttpContext here
  const session = ctx.session

  const cachedPermissions = session.get(`permissions_${user.id}`)

  if (cachedPermissions) {
    return cachedPermissions.includes(permission)
  }
}

Reproduction repo

No response

@thetutlage
Copy link
Member

thetutlage commented Jan 26, 2025

A complete reproduction repo is needed to debug the error. Feel free to comment here once you can provide a link to a repo

@thetutlage thetutlage self-assigned this Jan 26, 2025
@thetutlage thetutlage added the Type: Invalid Doesn't really belong here. Maybe use discussion threads? label Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Invalid Doesn't really belong here. Maybe use discussion threads?
Projects
None yet
Development

No branches or pull requests

2 participants