Skip to content

Commit 3cbfe82

Browse files
author
Sebastian BURGIN-FIX (ext)
committed
wip
1 parent 3a91579 commit 3cbfe82

3 files changed

Lines changed: 39 additions & 4 deletions

File tree

public/hot.disabled-for-lighthouse

Lines changed: 0 additions & 1 deletion
This file was deleted.

routes/console.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
use Illuminate\Support\Facades\Schedule;
44

55
Schedule::command('llm:fetch-analytics')->twiceDaily(5, 17);
6+
7+
Schedule::command('optimize:clear')->twiceDaily(6, 18);
8+
Schedule::command('responsecache:clear')->twiceDaily(6, 18);

tests/lighthouse/run.sh

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,48 @@ cd "$REPO_ROOT"
3030
echo "==> Building production assets"
3131
npm run build
3232

33+
# spatie/laravel-responsecache caches full HTML responses independently of
34+
# the Vite dev/prod check below — a page cached while dev mode was active
35+
# (or vice versa) keeps serving that stale snapshot forever, immune to the
36+
# worker warm-up loop further down. Always start from a clean slate.
37+
echo "==> Clearing response cache"
38+
php artisan responsecache:clear
39+
40+
HOT_STASH="${TMPDIR:-/tmp}/web-codebar-hot.$$"
3341
HOT_MOVED=0
3442
if [ -f public/hot ]; then
35-
mv public/hot public/hot.disabled-for-lighthouse
43+
mv public/hot "$HOT_STASH"
3644
HOT_MOVED=1
3745
fi
3846

3947
restore_hot() {
40-
if [ "$HOT_MOVED" = "1" ] && [ -f public/hot.disabled-for-lighthouse ]; then
41-
mv public/hot.disabled-for-lighthouse public/hot
48+
if [ "$HOT_MOVED" = "1" ] && [ -f "$HOT_STASH" ]; then
49+
mv "$HOT_STASH" public/hot
4250
fi
4351
}
4452
trap restore_hot EXIT
4553

54+
# Herd's PHP-FPM workers each cache file_exists(public/hot) independently, so a
55+
# worker that served requests before the mv above may keep reporting dev mode
56+
# for a while after. Hammer the homepage until every worker in the pool has
57+
# picked up the change before trusting any Lighthouse run against this build.
58+
echo "==> Waiting for all PHP-FPM workers to see the production build"
59+
stale=1
60+
for _ in $(seq 1 40); do
61+
stale=0
62+
for _ in $(seq 1 8); do
63+
if curl -sk "$BASE_URL/en-ch" | grep -q 'vite/client'; then
64+
stale=1
65+
break
66+
fi
67+
done
68+
[ "$stale" = "0" ] && break
69+
sleep 0.5
70+
done
71+
if [ "$stale" = "1" ]; then
72+
echo "!! Still seeing dev-mode markup after retries — results may be unreliable. Consider 'herd restart'."
73+
fi
74+
4675
# Filter pages.json down to requested names (all, if none given)
4776
if [ "$#" -gt 0 ]; then
4877
FILTER_JSON=$(printf '%s\n' "$@" | jq -R . | jq -s .)
@@ -58,6 +87,10 @@ echo "$PAGES" | jq -c '.[]' | while read -r page; do
5887
name=$(echo "$page" | jq -r '.name')
5988
path=$(echo "$page" | jq -r '.path')
6089
echo ">>> $name -> $path"
90+
# Same stale-worker guard, scoped to this page's own URL.
91+
for _ in $(seq 1 8); do
92+
curl -sk "${BASE_URL}${path}" | grep -q 'vite/client' || break
93+
done
6194
npx --yes lighthouse "${BASE_URL}${path}" \
6295
--output=json --output-path="$OUT_DIR/${name}.json" \
6396
--chrome-flags="--headless=new --ignore-certificate-errors" \

0 commit comments

Comments
 (0)