Skip to content

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

Description

@schloerke

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions