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

TypeError in Pulse::rememberUser() (Logout Event) #364

Closed
vintagesucks opened this issue May 7, 2024 · 1 comment · Fixed by #366
Closed

TypeError in Pulse::rememberUser() (Logout Event) #364

vintagesucks opened this issue May 7, 2024 · 1 comment · Fixed by #366
Assignees

Comments

@vintagesucks
Copy link

vintagesucks commented May 7, 2024

Pulse Version

1.0.0

Laravel Version

11.6.0

PHP Version

8.2.18

Livewire Version

3.4.12

Database Driver & Version

Description

Note: A similar problem was reported in #324, but closed due to lack of reproducibility.


We use Pulse::handleExceptionsUsing() to send silenced exceptions to Sentry via sentry/sentry-laravel like this:

# AppServiceProvider::boot()
Pulse::handleExceptionsUsing(fn (\Throwable $e) => Integration::captureUnhandledException($e));

If a user triggers a Logout event without an active session (for example, already logged out in another tab), this will throw a TypeError:

Laravel\Pulse\Pulse::rememberUser(): Argument #1 ($user) must be of type Illuminate\Contracts\Auth\Authenticatable, null given

We'd expect Pulse not to throw an error in this case, even if Pulse::handleExceptionsUsing() is used to handle silenced exceptions.

Steps To Reproduce

Reproduction repository: https://github.com/vintagesucks/repro-pulse-rememberuser-typeerror-authenticatable


Setup

composer create-project laravel/laravel repro-pulse-rememberuser-typeerror-authenticatable
cd repro-pulse-rememberuser-typeerror-authenticatable
composer require laravel/jetstream
php artisan jetstream:install inertia --no-interaction
npm install
npm run build
composer require laravel/pulse

Add the following to boot() in app/Providers/AppServiceProvider.php:

\Laravel\Pulse\Facades\Pulse::handleExceptionsUsing(fn (\Throwable $e) => throw($e));

Steps

  • Register
  • Open second application tab (/dashboard)
  • Log out in tab 1
  • Log out in tab 2

Result

Laravel\Pulse\Pulse::rememberUser(): Argument #1 ($user) must be of type Illuminate\Contracts\Auth\Authenticatable, null given
@timacdonald
Copy link
Member

Thanks, @vintagesucks. I've fixed this in #366.

I'll close this and we can track that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants