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

[LiveComponent] Cannot assign null to property Symfony\UX\LiveComponent\Twig\TemplateMap::$map of type array #1961

Open
tijnema opened this issue Jul 5, 2024 · 8 comments

Comments

@tijnema
Copy link
Contributor

tijnema commented Jul 5, 2024

Hi,

During deployment on our live environment we quite often get the error
Cannot assign null to property Symfony\UX\LiveComponent\Twig\TemplateMap::$map of type array

It seems to be related to a race condition with cache. Not sure how it occurs exactly, but it can easily be reproduced by deleting the live_components_twig_templates.map file from the cache folder.

@smnandre
Copy link
Member

smnandre commented Jul 5, 2024

Do you sometimes prune / delete your cache folder ? Or even with a CachePoolClearer maybe ?

@tijnema
Copy link
Contributor Author

tijnema commented Jul 5, 2024

We use Ansistrano for deployment. It places new version of the project in a new directory (with empty cache folder), and then switches a symlink to this new folder.

@smnandre
Copy link
Member

smnandre commented Jul 5, 2024

Do you warm the cache before the symlink ? The other possibility would be: do you change your APP_SECRET between deployments ?

@tijnema
Copy link
Contributor Author

tijnema commented Jul 5, 2024

APP_SECRET never changes. We currently do not warm the cache before symlink. That might just fix the issue.
The issue does remain when clearing the cache on a running instance though. I guess this piece of code could be written to work without existing cache too?

@smnandre
Copy link
Member

smnandre commented Jul 5, 2024

Well, yes and no :)

Yes it would work to "render" a component.

But if you clear the cache (without rebuilding it) while a user is browsing a page containing live components, that would break.

Maybe we should generate this file in the "build" directory and not the "cache" one ?

@RikudouSage
Copy link

Is there at least some workaround? It happens constantly in one app I create, only in the docker container, though.

@smnandre
Copy link
Member

Hi @RikudouSage, do you have APP_SECRET env variable configured?

@tijnema
Copy link
Contributor Author

tijnema commented Sep 2, 2024

@RikudouSage Maybe you should warm the cache before running the app ?

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

No branches or pull requests

4 participants