laravel / sanctum

Laravel Sanctum provides a featherweight authentication system for SPAs and simple APIs.
https://laravel.com/docs/sanctum
MIT License
2.74k stars 294 forks source link

Auth guard [sanctum] is not defined. #486

Closed nextgeni-mubbi closed 9 months ago

nextgeni-mubbi commented 9 months ago

Sanctum Version

3.2

Laravel Version

10.23

PHP Version

8.2

Database Driver & Version

MySQL 8 for macOs 14.1.1 on arm64 homebrew

Description

I was doing unit tests for my application and did around 238 tests with 489 assertions, when i run parallel unit testing then this error occurs "Auth guard [sanctum] is not defined." otherwise if a non-parallel tests suit is run then everything is fine.

Also this error comes randomly in parallel testing. i suspected the issue is due to the cache and i ran the "php artisan optimize:clear" then it works fine for few test runs. but again comes up in parallel testing after a while.

Here is the screenshot of the error:

image

after some google search i also find same issue with a user and someone also provided the cache clear solution: https://stackoverflow.com/questions/65924153/laravel-auth-guard-sanctum-is-not-defined

I am unable to find any specific error/issue with sanctum, can someone please look into this error and have a fix for sanctum or temporary fix for my parallel tests?

Steps To Reproduce

i dont know the exact steps but this is what i done:

  1. have too many tests using sanctum
  2. and run it in parallel unit testing.
driesvints commented 9 months ago

Hi there,

Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.