Potentially fix problems with refreshing HTML/CSS

master
Kuba Orlik 9 months ago
parent eee601226d
commit a66048d768

@ -4,6 +4,7 @@
- docker - docker
- docker-compose (version 2.6 or up) - docker-compose (version 2.6 or up)
- tmux
## Installation ## Installation
@ -11,8 +12,6 @@
npm install npm install
``` ```
Always use ./npm.sh when installing dependencies.
## Running the app in development mode ## Running the app in development mode
``` ```
@ -40,5 +39,5 @@ npx playwright install firefox
And then And then
``` ```
./npm.sh run test npm run test
``` ```

@ -1,3 +1,3 @@
{ {
"delay": "100" "delay": "500"
} }

@ -85,25 +85,69 @@ export default function html(
setTimeout(resolve, time); setTimeout(resolve, time);
}); });
let last_known_start_timestamp = 0; const APP_DOWN_ERROR_MESSAGE = "App is currently down";
function get_status() {
return fetch("/status.json").then((r) => r.json());
}
async function wait_for_run_id_to_change() {
let first_timestamp;
try {
const { started_at, status } = await get_status();
first_timestamp = started_at;
} catch (e) {
await wait_for_app_to_be_stable();
return;
}
if (!first_timestamp) {
throw new Error(APP_DOWN_ERROR_MESSAGE);
}
async function wait_for_app_restart() {
while (true) { while (true) {
const { started_at, status } = await fetch( const { started_at, status } =
"/status.json" await get_status().catch(() => ({
) started_at: first_timestamp,
.then((r) => r.json())
.catch(() => ({
started_at: last_known_start_timestamp,
})); }));
if (started_at !== last_known_start_timestamp) { if (started_at !== first_timestamp) {
last_known_start_timestamp = started_at;
return; return;
} }
await sleep(100); await sleep(100);
} }
} }
async function wait_for_app_to_be_stable(n = 3) {
console.log("Waiting for app to be stable....");
let counter = 0;
while (true) {
const { status } = await get_status().catch((e) => ({
status: "down",
}));
if (status == "running") {
console.log(counter);
counter++;
} else {
counter = 0;
}
if (counter == n) {
return;
}
await sleep(100);
}
}
async function wait_for_app_restart() {
try {
await wait_for_run_id_to_change();
} catch (e) {
if (e.message !== APP_DOWN_ERROR_MESSAGE) {
throw e;
}
}
await wait_for_app_to_be_stable();
}
(async function () { (async function () {
const { started_at, status } = await fetch( const { started_at, status } = await fetch(
"/status.json" "/status.json"

Loading…
Cancel
Save