-
Notifications
You must be signed in to change notification settings - Fork 23
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
refresh infinite loop issue #19
Comments
I'm facing with the same issue |
I'm also facing the same issue when I enable the reloadOnDowngrade attribute. after the page refresh it keeps showing the version from meta.json as the new version found and keeps reloading the page. |
Check package json and change number of version , |
I generally don't really bother with bumping the version in the // post-build.cjs
const fs = require("fs");
const cp = require("child_process");
const packageJson = require("./package.json");
const commitHash = cp
.execSync("git rev-parse --short HEAD")
.toString()
.replace("\n", "");
const meta = {
version: packageJson.version + "-" + commitHash,
};
const data = JSON.stringify(meta);
if (fs.existsSync("dist")) {
fs.writeFileSync("dist/meta.json", data, { encoding: "utf8" });
console.log('postbuild: Wrote application metadata to "dist/meta.json"');
console.log("postbuild:", data);
} // package.json
{
"scripts": {
"postbuild": "node ./postbuild.cjs"
}
} Then in the app, I inject the same value as an environment variable for the When using Vite, it looks like this. Other frameworks should have their own injection steps in their documentation, or you could simply use a pre script that writes a file into your src directory with this value. // vite.config.ts
import cp from "child_process";
import path from "path";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import packageJson from "./package.json";
const commitHash = cp
.execSync("git rev-parse --short HEAD")
.toString()
.replace("\n", "");
const APP_VERSION = `${packageJson.version}-${commitHash}`;
export default defineConfig({
plugins: [react()],
define: {
"import.meta.env.APP_VERSION": JSON.stringify(APP_VERSION),
},
}); |
This glitch may be due to the browser cache not updating/erasing on refresh and that it keeps caching the old version/file of the react app. So, the script keeps asking for a new version on refresh and it creates a loop because the new version never comes. |
I installed the package and I tested it in my react app. I am not sure for some reason the react app keeps refreshing again and again. How can this issue be resolved?
The text was updated successfully, but these errors were encountered: