livewire / volt

Volt is an elegantly crafted functional API for Livewire.
https://livewire.laravel.com/docs/volt
MIT License
340 stars 19 forks source link

Exception when using anonymous component #118

Closed punyflash closed 17 hours ago

punyflash commented 1 day ago

Volt Version

1.6.5

Laravel Version

11.27.2

PHP Version

8.3.12

Database Driver & Version

No response

Description

When navigating between pages using back/front browser buttons, sometimes I get an exception:

[2024-10-09 22:46:33] local.ERROR: Livewire\Volt\FragmentAlias::encode(): Argument #2 ($path) must be of type string, null given, called in /var/www/html/vendor/livewire/volt/src/Precompilers/ExtractFragments.php on line 98 {"userId":1,"exception":"[object] (TypeError(code: 0): Livewire\\Volt\\FragmentAlias::encode(): Argument #2 ($path) must be of type string, null given, called in /var/www/html/vendor/livewire/volt/src/Precompilers/ExtractFragments.php on line 98 at /var/www/html/vendor/livewire/volt/src/FragmentAlias.php:15)
[stacktrace]
#0 /var/www/html/vendor/livewire/volt/src/Precompilers/ExtractFragments.php(98): Livewire\\Volt\\FragmentAlias::encode()
#1 /var/www/html/vendor/livewire/volt/src/Precompilers/ExtractFragments.php(50): Livewire\\Volt\\Precompilers\\ExtractFragments->directive()
#2 [internal function]: Livewire\\Volt\\Precompilers\\ExtractFragments->Livewire\\Volt\\Precompilers\\{closure}()
#3 /var/www/html/vendor/livewire/volt/src/Precompilers/ExtractFragments.php(38): preg_replace_callback()
#4 /var/www/html/vendor/livewire/volt/src/VoltServiceProvider.php(44): Livewire\\Volt\\Precompilers\\ExtractFragments->__invoke()
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/View/Compilers/BladeCompiler.php(262): Livewire\\Volt\\VoltServiceProvider->Livewire\\Volt\\{closure}()
#6 /var/www/html/vendor/imanghafoori/laravel-microscope/src/Features/CheckUnusedBladeVars/ViewsData.php(35): Illuminate\\View\\Compilers\\BladeCompiler->compileString()
#7 /var/www/html/vendor/imanghafoori/laravel-microscope/src/Features/CheckUnusedBladeVars/UnusedVarsInstaller.php(34): Imanghafoori\\LaravelMicroscope\\Features\\CheckUnusedBladeVars\\ViewsData->readTokenizedVars()
#8 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Imanghafoori\\LaravelMicroscope\\Features\\CheckUnusedBladeVars\\UnusedVarsInstaller::Imanghafoori\\LaravelMicroscope\\Features\\CheckUnusedBladeVars\\{closure}()
#9 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php(43): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#10 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(83): Illuminate\\Container\\Util::unwrapIfClosure()
#11 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\\Container\\BoundMethod::callBoundMethod()
#12 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(690): Illuminate\\Container\\BoundMethod::call()
#13 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1420): Illuminate\\Container\\Container->call()
#14 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(218): Illuminate\\Foundation\\Application->terminate()
#15 /var/www/html/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->terminate()
#16 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/resources/server.php(23): require_once('...')
#17 {main}
"} 

The behavior is really weird, and I do not understand it completely.

Steps To Reproduce

  1. Have an anonymous Volt component with changeable state.
  2. Update state somehow.
  3. Navigate to other page.
  4. Navigate back.
crynobone commented 1 day ago

Hey there, thanks for reporting this issue.

We'll need more info and/or code to debug this further. Can you please create a repository with the command below, commit the code that reproduces the issue as one separate commit on the main/master branch and share the repository here?

Please make sure that you have the latest version of the Laravel installer in order to run this command. Please also make sure you have both Git & the GitHub CLI tool properly set up.

laravel new bug-report --github="--public"

Do not amend and create a separate commit with your custom changes. After you've posted the repository, we'll try to reproduce the issue.

Thanks!

punyflash commented 17 hours ago

Issue was caused by other package during updates when variable was not used in template: imanghafoori1/laravel-microscope