-
-
Notifications
You must be signed in to change notification settings - Fork 169
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
Updating to a new version from .exe causes caching issues #431
Comments
Are there any errors in the
We can't know whether some of these files are the user's files or whether they're application files. This would need to be up to the application (i.e. your code) to control. I don't recommend this method - it's too easy for something to go wrong here and lose essential data. What would be better imo would be to try to understand exactly where it's failing and fixing the root cause. I suspect this has something to do with caches in the storage directory ( But this is largely dependent on how your specific application behaves. I'll try to run some arbitrary builds this week to see if I can reproduce, but I may need a copy of your repo to truly understand the problem. |
The repository is unfortunately a private company repository. I will attempt to reproduce it tomorrow with the most basic setup. It will cost some time but I have some ideas. There were no logfiles as no server side errors occured. Client side was missing JS methods. |
@simonhamp here are binaries with a very similar issue: view cache being outdated. https://github.com/RobertWesner/native-win-problems/tree/main Download: https://www.mediafire.com/file/ts2pod0lrkbnkos/Laravel-1..zip/file Reproduce:
|
I was able to narrow it down to In my opinion, the views folder should be emptied on install/update if it exists. It gets rebuilt automatically. No user files should be affected by this. <?php
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
// FIX VERSION CACHE PROBLEM>>>
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
(function () {
$appData = env('APPDATA');
if ($appData) {
$env = Dotenv\Dotenv::createArrayBacked(__DIR__ . '/../')->load();
$projectAppData = $appData . '/' . strtolower($env['APP_NAME']);
$versionFile = $projectAppData . '/version.txt';
$nativeAppVersion = $env['NATIVEPHP_APP_VERSION'];
if (!file_exists($versionFile) || file_get_contents($versionFile) !== $nativeAppVersion) {
$call = function ($recursive, string $path): void
{
if (is_dir($path)) {
foreach (array_diff(scandir($path), ['.', '..']) as $file) {
$recursive($recursive, $path . '/' . $file);
}
} else {
unlink($path);
}
};
$call($call, $projectAppData . '/storage/framework/views');
file_put_contents($versionFile, $nativeAppVersion);
}
}
})();
}
// <<<FIX VERSION CACHE PROBLEM
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {
//
})
->withExceptions(function (Exceptions $exceptions) {
//
})->create(); |
@simonhamp were you able to reproduce it? It would be great to not rely on a hack to clear cache. Are there plans on how to move forward with this issue? |
I think the right solution here is for us to explicitly rebuild the view cache when we detect the updated version has been installed, i.e. by running |
This is coming. |
What were you trying to do?
I was attempting to update the version of installed NativePHP software on Windows 11.
What happened?
The Update went well right until the software started. The JS Client fails due to
%appdata%\APPNAME\storage
being outdated. Deleting the storage folder while the app was closed fixed the issue but expecting administration to manually delete files on end user PCs just to update software is unreasonable.How to reproduce the bug
%appdata%
persists as it should).Results in: Client side Javascript errors for Bootstrap.Results in: outdated View. View also links to invalid/outdated Javascript which first made me think it was a JS cache issue. It is a view cache issue.
Package Versions
^0.8.5 -> latest | old version was 0.7.4
PHP Version
^8.3.0
Laravel Version
^11.31
Node Version
latest
Which operating systems have you seen this occur on?
Windows
OS version
Windows 11
Notes
A simple solution would have the installer force delete
%appdata%\APPNAME\storage
since it may contain outdated bundled files and views. The storage gets rebuilt automatically on app launch.The current attempt to hijack bootstrap/app.php to automagically delete storage on version mismatch with a version.txt to compare has failed so far.
The text was updated successfully, but these errors were encountered: