inertiajs / inertia

Inertia.js lets you quickly build modern single-page React, Vue and Svelte apps using classic server-side routing and controllers.
https://inertiajs.com
MIT License
6.3k stars 423 forks source link

Fix: in setPage if no component return empty promise #1786

Closed zcuric closed 5 months ago

zcuric commented 8 months ago

This PR:

In certain scenarios when the user is moving back and forth with the browser page data is lost and setPage tries to resolve an empty component, resulting in an undefined error being seen. Multiple Interia users have reported this issue and we are experiencing it in our project also (see attached image). Error is thrown from laravel-vite-plugin Intertia helper resolvePageComponent, but in general, this shouldn't happen if there is no page.

page object should be typed more strictly, but that is larger effort.

Also, when debugging I've also noticed that visitId is always an empty object, so the if statement in then always gets executed because {} === {}. I've never seen that visitId had any meaningful value.

image

Hasan-Mir commented 8 months ago

Thanks, this PR fixes the useRemember's bug #1766

zcuric commented 7 months ago

1784 already fixes this issue and also fixes a security issue. @Hasan-Mir can you check if the mentioned PR fixes your issue as well? Thanks.

I'll close this one once #1784 is merged.

Hasan-Mir commented 7 months ago

@zcuric Yes, it fixes the issue.

driesvints commented 5 months ago

Thank you but will close this one in favour of https://github.com/inertiajs/inertia/pull/1784

zcuric commented 5 months ago

@driesvints thank you! 🖖🏻