Skip to content

Octane + OpenSwoole: Auth::user() only works on first request #222

@leonvd6

Description

@leonvd6

Subject of the issue

I've migrated my environment to Octane+Swoole and when making a request with jwt.auth middleware in api.php, the user is found using Auth::user() or $request->user(), but the subsequent request return null.

Your environment:

Q A
Bug? yes
New Feature? no
Framework Laravel
Framework version 9.52.9
Package version 2.1.0
PHP version 8.1.20

Steps to reproduce

dd(Auth::user()) in a controller API request twice in a row. Running php artisan octane:reload fixes the issue for the next request only.

Expected behaviour

Auth::user() should return the user object on every request, not just the first one.

Actual behaviour

Auth::user() returns a user on the first request, then null on any requests after that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions