[Bug]: Dev servers start on page loads with Developer Tools turned off
まだ誰も着手していません。
評価
調査の方向性
Start with the shutdown function in server.php, which rewrites herd.json to store lastSite under a lock, and with HerdConfiguration::loadConfigFile(), which reads the same file without one. Run the race.php script from the report against herd.json to reproduce the empty reads. Done means a concurrent reader can never see an empty file and treat aiAssistant as enabled. The fix needs maintainer agreement on the locking approach.
索引モデルが issue の本文から書いたものです。
説明
Platform
macOS
Operating system version
macOS Sequoia 15.6.1 (24G90)
System architecture
ARM64 (M1, M2, etc)
Herd Version
2.0.3 (Build: 72)
PHP Version
No response
Bug description
With "Enable Herd Developer Tools" off (aiAssistant.enabled: false in herd.json), Herd still occasionally starts npm run dev for a site I'm browsing, under herd-devtools-helper, and leaves a public/hot behind.
I traced it to a race on herd.json. The shutdown function in server.php rewrites the file on every request to store lastSite, locking it, truncating it and then writing it. But HerdConfiguration::loadConfigFile() reads it with a plain file_get_contents() and no lock. A request that reads it between the truncate and the write gets an empty string, fill() ends up with no aiAssistant key, and since a missing enabled defaults to true, aiAssistantEnabled() returns true. LaravelValetDriver::ensureViteDevServer() then calls /ai/dev-ensure and the dev server boots.
So any site that gets concurrent requests (a page and its XHRs, an Inertia app polling etc.) hits it eventually.
Steps to reproduce
- Save this as
race.php, it readsherd.jsonthe same wayHerdConfigurationdoes:
<?php
$until = microtime(true) + 15;
$reads = $empty = 0;
while (microtime(true) < $until) {
$reads++;
if (file_get_contents($argv[1]) === '') {
$empty++;
}
}
echo "$empty empty reads out of $reads\n";
- Run it while firing concurrent requests at any Laravel site (POSTs, so nothing actually boots):
php race.php ~/Library/Application\ Support/Herd/config/herd.json &
seq 400 | xargs -P 12 -I{} curl -s -k -o /dev/null -X POST https://example.test/
I get 72 empty reads out of ~520k. Each of those would read as AI assistant enabled.
Relevant log output
When it happens the unified log shows:
[HerdDevtools] vite.start skipped for lido: queued until the worktree resolves
[HerdDevtools] ensureRepo path=/Users/jack/Projects/lido nonGit=false
[HerdDevtools] worktree.create useRepoPath=true repoId=49101c7f
[HerdDevtools] worktree.created repoId=49101c7f id=e82bb067 branch=main
And /var/tmp/herd-dev-ensure-<md5 of site> is touched in the same second.
- 主要言語
- 言語のデータがありません
- スター
- 125
- フォーク
- 1
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
beyondcode/herd-community のほかの issue
-
[Bug]: PHP 8.3 php.ini missing auto_prepend_file and herd-ext extension lines (dump() undefined)オープンmacOS
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
beyondcode/herd-community#1693 ·
-
macOS
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
beyondcode/herd-community#1602 ·
-
macOS
難易度 4/5 3〜5日 初心者へのやさしさ 15/100
beyondcode/herd-community#1799 · コメント 3 件 ·
-
macOS
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
beyondcode/herd-community#1797 ·
-
[2.0.3] PHP-FPM dies shortly after login, first request each morning hits "Herd is fixing this site"オープンmacOS
難易度 4/5 3〜5日 初心者へのやさしさ 18/100
beyondcode/herd-community#1796 · コメント 1 件 ·
beyondcode/herd-community の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
dependents/node-precinct#167 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ccch1mneyyy/dsh-Go#729 ·
メンテナーはふだん 1 日以内に返信
-
enhancement priority:low size:small
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
RonaldHensbergen/composable-data-stack#1205 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100