Studio: files added to `public/` return 404 until the project is reopened, when `public/` did not exist at open

オープン 初心者向け
#16 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
react, typescript, vite
領域
devtools

調査の方向性

packages/studio/src/start-studio.ts から始めてください。ここでは publicDir が Vite の createServer に渡されています。packages/studio/src/scaffold-project.ts では src/ を public/ なしで書き出しています。再現手順は、public/ のないプロジェクトを開き、そこにファイルを追加して、/audio/x.wav にリクエストすることです。404 が返るはずです。完了条件は、プロジェクトを開き直さずにファイルが配信されること、そして scaffold が public/ を作成することです。

索引モデルが issue の本文から書いたものです。

説明

bug

Summary

If a project has no public/ directory when Studio opens it, files added to public/ afterwards are never served. The assets panel lists them, but the dev server answers 404 for every one, so <Audio> plays silence and images and fonts are missing, with no error anywhere. It stays that way until the project is closed and opened again.

Every project created from Studio's workspace picker starts in this state, because the scaffold writes src/ and no public/.

Reproduction

Studio 0.2.6 (rendiv studio --workspace /workspace --port 3000 --host 0.0.0.0, Linux in Docker, Vite 6.4.1).

  1. Create a project from the workspace picker and leave it open.
  2. mkdir -p public/audio && cp x.wav public/audio/
  3. GET /__rendiv_api__/assets/list lists audio/x.wav. GET /audio/x.wav returns 404.
  4. A file written later, straight into the public/ that now exists, returns 404 too.
  5. POST /__rendiv_api__/workspace/back, then POST /__rendiv_api__/workspace/open with the same project path. Every file from steps 2 to 4 now returns 200, and from here on a new file in public/ is served within a couple of seconds.

Cause

packages/studio/src/start-studio.ts passes publicDir: path.resolve(cwd, publicDir) to createServer. Vite reads the public file list once at startup (an empty set when the directory is missing), and servePublicMiddleware only serves paths that are in that set. The set should grow from the watcher's add events, but when the directory did not exist at startup it never does. --host turns on usePolling, which may be part of it; I did not trace it further into chokidar.

Suggested fix

  • In startStudio, create the directory before createServer (fs.mkdirSync(path.resolve(cwd, publicDir), { recursive: true })). It already creates .studio/ there.
  • In packages/studio/src/scaffold-project.ts, create public/ next to src/, and add it to the create-rendiv template as well (for example with a .gitkeep).
主要言語
TypeScript
スター
159
フォーク
32
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

thecodacus/rendiv のほかの issue

thecodacus/rendiv の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。