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

refactor: handle repeated livewire request exceptions #702

Merged

Conversation

alexbarnsley
Copy link
Member

@alexbarnsley alexbarnsley commented Nov 23, 2023

Summary

https://app.clickup.com/t/86dqmbkz9

Created a JS handler to watch for failed livewire requests. When the failure count reaches 10 failed requests in a row (per component), the page will reload which will force the component to reload. There are a few possible reasons a livewire request could fail:

  • an error with the backend of the component
  • there is livewire corruption (e.g. the backend has properties which the frontend did not) - common with new releases
  • lost internet connection?

10 repeatedly failed attempts to update a component seemed like a safe number. The Price Ticker is updated every 30 seconds so it would take ~5 minutes for this to trigger. However, the delegate monitor polls every second (ish) so that could take 10-20 seconds before triggering a page reload.

To test:

  • Open resources/views/livewire/price-ticker.blade.php
  • Change the polling from 30s to 1s
  • Load any page of your local explorer in your browser and leave it open
  • Open app/Http/Livewire/PriceTicker.php
  • Add public string $price; to the properties
  • Add $this->price = md5((string) now()->unix()); to the mount method
  • Save
  • Should get the exception in the window you opened
  • Wait for 10 failed requests
  • Page should reload

Checklist

  • I checked my UI changes against the design and there are no notable differences
  • I checked my UI changes for any responsiveness issues
  • I checked my UI changes in light AND dark mode
  • I checked my (code) changes for obvious issues, debug statements and commented code
  • I opened a corresponding card on Clickup for any remaining TODOs in my code
  • I added a short description on how to test this PR (if necessary)
  • Documentation (if necessary)
  • Tests (if necessary)
  • Ready to be merged

@alexbarnsley alexbarnsley merged commit 0fe81b6 into develop Dec 4, 2023
9 checks passed
@alexbarnsley alexbarnsley deleted the refactor/handle-concurrent-livewire-exceptions branch December 4, 2023 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants