webR: synchronous metadata.rds probe re-runs on every app start and 404s

Aperta
#237 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
typescript

Direzione di ricerca

Inizia da src/hooks/useWebR.tsx:274-287, in .mount_vfs_images(), e traccia come metadata_url e il risultato del probe vengono utilizzati durante l'avvio dell'app. Controlla lo smoke test degli esempi di #236 mentre passi da un esempio all'altro, per confermare che la richiesta non venga ripetuta, che il fallback continui a funzionare per un 404 e che l'avvio non sia più bloccato dal probe sincrono.

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

Descrizione

What

Every R app start fires a synchronous HEAD request for shinylive/webr/packages/metadata.rds, which 404s on shinylive's own build. Found while building the examples smoke test (#236) — it shows up once per R example in the CI logs:

[WebServer] "HEAD /r/shinylive/webr/packages/metadata.rds HTTP/1.1" 404 -

Where

src/hooks/useWebR.tsx:274-287, in .mount_vfs_images():

found <- webr::eval_js(glue::glue("
  var xhr = new XMLHttpRequest();
  xhr.open('HEAD', '{metadata_url}', false);
  xhr.send();
  (xhr.status >= 200 && xhr.status < 300)
"))

Why this isn't just log noise

The 404 itself is by design — the comment says as much ("Attempt this download quietly, if no metadata exists we can still continue"), and the fallback works correctly. Two things still look worth a second look:

  1. The XHR is synchronous (xhr.open(..., false)), so it blocks the webR worker thread for a full network round trip during app startup.

  2. It re-probes on every app start, not once per session. Measured in a warm session by counting requests while switching examples:

    after boot + first app:        1
    after switching to Shiny Text: 2
    after switching to Reactivity: 3
    after switching to Sliders:    4
    

    The result cannot change within a session, so runs 2..n are pure overhead on a path users wait on.

metadata.rds is presumably present in deployments that ship prebuilt VFS package images; it is absent from the build this repo produces, so shinylive.io pays the miss every time.

Suggested fix

Cache the probe result for the lifetime of the session, and make the request async if the surrounding code allows it. If metadata.rds is never expected in this repo's own build, skipping the probe unless something opts in would avoid it entirely.

Not blocking anything

webR swallows the 404 without raising a console error, so it does not fail the new smoke test and no example is broken by it. Filing separately per discussion on #236.

Lingua principale
TypeScript
Stelle
253
Fork
25
Merge medio
6g 22h
PR unite (30g)
13

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 posit-dev/shinylive

Tutte le issue di posit-dev/shinylive

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.