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

Hot reloading doesn't work, the application is always fully reloading. #513

Closed
antran22 opened this issue Sep 30, 2023 · 0 comments · Fixed by #514
Closed

Hot reloading doesn't work, the application is always fully reloading. #513

antran22 opened this issue Sep 30, 2023 · 0 comments · Fixed by #514

Comments

@antran22
Copy link
Contributor

antran22 commented Sep 30, 2023

Description

Hot reloading doesn't work, the application is always fully reloading even on minor changes.

Reproduction setup

Bundler: Webpack

The setup is a bit complex, we want to develop Preact components over a pre-existing backend. The Preact component is wrapped into a custom component using preact-custom-element, then injected into the backend as plain HTML.

After investigating, we found the error by patching

self.location.reload();
to print an error before issuing a full reload. This gives us the following error message.

TypeError: can't access property "__P", vnode.__c is null
    replaceComponent index.js:57
    ...

The faulty line:

if (!vnode.__c.__P) return;

Analysis: this is an unsafe deep access. Patching to if (!vnode.__c || !vnode.__c.__P) return; keeps the error from throwing, and allow the hot reload process to continue.

I have not fully understood the full cause of why vnode.__c is null, however by patching this I managed to get hot reloading working.

A PR with this patch is created #514

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

Successfully merging a pull request may close this issue.

1 participant