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

Aperta Adatta ai principianti
#16 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react, typescript, vite
Ambito
devtools

Direzione di ricerca

Inizia da packages/studio/src/start-studio.ts, dove publicDir viene passato a createServer di Vite, e da packages/studio/src/scaffold-project.ts, che scrive src/ senza public/. Per riprodurre, apri un progetto senza public/, aggiungi un file lì e richiedilo a /audio/x.wav, che dovrebbe restituire 404. È completato quando il file viene servito senza riaprire il progetto e lo scaffold crea public/.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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).
Lingua principale
TypeScript
Stelle
159
Fork
32
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di thecodacus/rendiv

Tutte le issue di thecodacus/rendiv

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.