❓ Support

Attempted to lazy load [reactionTypes] on model [Waterhole\Models\ReactionSet] but lazy loading is disabled

My project is a waterhole integration into a laravel 10 app.

My client has started using the forum in production and suddenly gets following error trying to access the frontend of the forum:

Attempted to lazy load [reactionTypes] on model [Waterhole\Models\ReactionSet] but lazy loading is disabled

Despite this error, I don't find any reference in the codebase indicating that lazy loading is disabled like "Model::preventLazyLoading()" or other methods to prevent lazy loading

The rest of the error log looks like this:

... (lots of preceeding html and js)

</pre><script>Sfdump(\"sf-dump-848759880\", {\"maxDepth\":3,\"maxStringLength\":160})</script>
"}},"userId":6,"exception":"[object] (Spatie\\LaravelIgnition\\Exceptions\\ViewException(code: 0): Attempted to lazy load [reactionTypes] on model [Waterhole\\Models\\ReactionSet] but lazy loading is disabled. at /vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php:564)
[stacktrace]
#0 /site/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(523): Illuminate\\Database\\Eloquent\\Model->handleLazyLoadingViolation('...')
#1 /site/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(454): Illuminate\\Database\\Eloquent\\Model->getRelationValue('...')
#2 /site/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(2226): Illuminate\\Database\\Eloquent\\Model->getAttribute('...')
#3 /site/vendor/waterhole/core/src/View/Components/Reactions.php(32): Illuminate\\Database\\Eloquent\\Model->__get('...')
#4 /site/vendor/laravel/framework/src/Illuminate/View/Component.php(102): Waterhole\\View\\Components\\Reactions->__construct(Object(Waterhole\\Models\\Post))
#5 /site/storage/framework/views/6b83bb6e4f22ff2a0d76a72615e41371.blade.php(1): Illuminate\\View\\Component::resolve(Array)
#6 /site/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(123): require('...')
#7 /site/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(124): Illuminate\\Filesystem\\Filesystem::Illuminate\\Filesystem\\{closure}()
#8 /site/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(58): Illuminate\\Filesystem\\Filesystem->getRequire('...', Array)
#9 /site/vendor/livewire/livewire/src/Mechanisms/ExtendBlade/ExtendedCompilerEngine.php(22): Illuminate\\View\\Engines\\PhpEngine->evaluatePath('...', Array)
#10 /site/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(72): Livewire\\Mechanisms\\ExtendBlade\\ExtendedCompilerEngine->evaluatePath('...', Array)
#11 /site/vendor/livewire/livewire/src/Mechanisms/ExtendBlade/ExtendedCompilerEngine.php(10): Illuminate\\View\\Engines\\CompilerEngine->get('...', Array)
#12 /site/vendor/laravel/framework/src/Illuminate/View/View.php(207): Livewire\\Mechanisms\\ExtendBlade\\ExtendedCompilerEngine->get('...', Array)
#13 /site/vendor/laravel/framework/src/Illuminate/View/View.php(190): Illuminate\\View\\View->getContents()
#14 /site/vendor/laravel/framework/src/Illuminate/View/View.php(159): Illuminate\\View\\View->renderContents()
#15 /site/vendor/laravel/framework/src/Illuminate/View/Concerns/ManagesComponents.php(103): Illuminate\\View\\View->render()
#16 /site/vendor/waterhole/core/resources/views/components/post-list-item.blade.php(37): Illuminate\\View\\Factory->renderComponent()
#17 /site/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(123): require('...')
#18 /site/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(124): Illuminate\\Filesystem\\Filesystem::Illuminate\\Filesystem\\{closure}()
#19 /site/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(58): Illuminate\\Filesystem\\Filesystem->getRequire('...', Array)
#20 /site/vendor/livewire/livewire/src/Mechanisms/ExtendBlade/ExtendedCompilerEngine.php(22): Illuminate\\View\\Engines\\PhpEngine->evaluatePath('...', Array)
#21 /site/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(72): Livewire\\Mechanisms\\ExtendBlade\\ExtendedCompilerEngine->evaluatePath('...', Array)
#22 /site/vendor/livewire/livewire/src/Mechanisms/ExtendBlade/ExtendedCompilerEngine.php(10): Illuminate\\View\\Engines\\CompilerEngine->get('...', Array)
#23 /site/vendor/laravel/framework/src/Illuminate/View/View.php(207): Livewire\\Mechanisms\\ExtendBlade\\ExtendedCompilerEngine->get('...', Array)

Any idea what the problem could be?

Thanks,
Emmanuel

Answered by Toby Toby

Hi @Emmanuel Ingelaere, thanks for posting and working through this issue transparently, and sorry for any inconvenience it's caused in your production environment.

While the bulk of Model::shouldBeStrict() issues were solved in v0.4.6, upon a little further digging, it looks like you uncovered a bug where a lazy loading error could still occur with some particular configurations of reactions - specifically, multiple reaction sets containing only a single reaction type. I've committed a fix for this which will be included in the next release.

Thanks for your PR to fix the Dutch translation - a great first contribution! ⭐️

View Answer

⁨7⁩ ⁨Comments⁩

Now the control panel is also not accessible anymore, the forum is using the dutch language:

Expected token: "=" somewhere in "channel- slug-url-label = Dit kanaal is toegankelijk op:
". {"view":{"view":"site/vendor/waterhole/core/resources/views/cp/dashboard.blade.php","data":{"errors":"<pre class=sf-dump id=sf-dump-849146141 data-indent-pad=\" \"><span class=sf-dump-note>Illuminate\Support\ViewErrorBag</span> {<a class=sf-dump-ref>#6958</a><samp data-depth=1 class=sf-dump-expanded>
#<span class=sf-dump-protected title=\"Protected property\">bags</span>: []
</samp>}
</pre><script>Sfdump(\"sf-dump-849146141\", {\"maxDepth\":3,\"maxStringLength\":160})</script>
"}},"userId":6,"exception":"[object] (Spatie\LaravelIgnition\Exceptions\ViewException(code: 0): Expected token: \"=\" somewhere in \"channel- slug-url-label = Dit kanaal is toegankelijk op:
\". at site/vendor/jrmajor/fluent/src/Parser/FluentParser.php:64)
[stacktrace]
#0 site/vendor/waterhole/core/src/Translation/FluentTranslator.php(134): Major\Fluent\Parser\FluentParser->parse('...')
#1 site/vendor/waterhole/core/src/Translation/FluentTranslator.php(142): Waterhole\Translation\FluentTranslator->Waterhole\Translation\{closure}()
#2 site/vendor/waterhole/core/src/Translation/FluentTranslator.php(179): Waterhole\Translation\FluentTranslator->loadPath('...', '...', '...')
#3 site/vendor/waterhole/core/src/Translation/FluentTranslator.php(117): Waterhole\Translation\FluentTranslator->loadNamespaced('...', '...', '...')
#4 site/vendor/waterhole/core/src/Translation/FluentTranslator.php(108): Waterhole\Translation\FluentTranslator->loadFtl('...', '...', '...')
#5 site/vendor/waterhole/core/src/Translation/FluentTranslator.php(83): Waterhole\Translation\FluentTranslator->getBundle('...', '...', '...')
#6 site/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(923): Waterhole\Translation\FluentTranslator->get('...', Array, '...')
#7 site/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(958): trans('...', Array, NULL)
#8 site/vendor/waterhole/core/resources/views/cp/dashboard.blade.php(1): __('...')
#9 site/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(123): require('...')
#10 site/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(124): Illuminate\Filesystem\Filesystem::Illuminate\Filesystem\{closure}()

All problems solved!

After commenting out Model::shouldBeStrict(); in my project, the lazyloading error dissapeared.

The control panel problem was actually an accidental space in the dutch translation file key. I filed a pull request for that and hope I did that the right way, as I'm taking my first steps in the contribution world.

Answer
Toby Toby Waterhole Founder May 9, 2024
In reply to E Emmanuel Ingelaere

Hi @Emmanuel Ingelaere, thanks for posting and working through this issue transparently, and sorry for any inconvenience it's caused in your production environment.

While the bulk of Model::shouldBeStrict() issues were solved in v0.4.6, upon a little further digging, it looks like you uncovered a bug where a lazy loading error could still occur with some particular configurations of reactions - specifically, multiple reaction sets containing only a single reaction type. I've committed a fix for this which will be included in the next release.

Thanks for your PR to fix the Dutch translation - a great first contribution! ⭐️

Have the same issue

Expected token: "=" somewhere in "channel- slug-url-label = Dit kanaal is toegankelijk op: ".

when loading the control panel (/cp). Waterhole is on v0.4.7, but remarkably also in the dutch language