webr icon indicating copy to clipboard operation
webr copied to clipboard

Mounting with non-standard metadata URL does not work / Mounting with `Blob` objects from main JS thread does not work

Open dipterix opened this issue 1 year ago • 5 comments

Dear webr devs,

I generated my dataset using rwasm::file_packager. However, when I try to load it directly from JS, the browser complains

Uncaught (in promise) TypeError: can't convert undefined to BigInt
    doStat https://webr.r-wasm.org/v0.4.2/R.bin.js:2061
    ___syscall_stat64 https://webr.r-wasm.org/v0.4.2/R.bin.js:2061

To replicate, you can download the data from here: https://zenodo.org/records/13825852

When loading from webr::mount locally, everything is fine.

This is a screenshot of results with webr::mount: it can read the files correctly:

image

However, when I try to deploy the website and use the URL

(For you to test the URL, I'm using the zenodo API with CORS. Just FYI the URL has no issue. The error exists when testing it locally too)

const path = "/home/web_user/rave_data";
const data = "https://zenodo.org/api/records/13825852/files/project-demo-minimal.data/content";
const meta = "https://zenodo.org/api/records/13825852/files/project-demo-minimal.js.metadata/content";

await webR.FS.mkdir(path);

// Download image data
const _data = await fetch(data);
const _metadata = await fetch(meta);

// Mount image data
const options = {
  packages: [{
    blob: await _data.blob(),
    metadata: await _metadata.json(),
  }],
}

await webR.FS.mount("WORKERFS", options, path);

await mainWebR.evalR("readLines('~/rave_data/raw_dir/DemoSubject/rave-imaging/fs/mri/transforms/talairach.xfm')")

Error:

Uncaught (in promise) TypeError: can't convert undefined to BigInt
    doStat https://webr.r-wasm.org/v0.4.2/R.bin.js:2061
    ___syscall_stat64 https://webr.r-wasm.org/v0.4.2/R.bin.js:2061
    safeEval blob:http://localhost:3530/40ef506b-683b-40b4-9dfc-512b84137000:2087
    captureR blob:http://localhost:3530/40ef506b-683b-40b4-9dfc-512b84137000:9289
    evalR blob:http://localhost:3530/40ef506b-683b-40b4-9dfc-512b84137000:9338
    dispatch blob:http://localhost:3530/40ef506b-683b-40b4-9dfc-512b84137000:8948
    PostMessageChannelWorker blob:http://localhost:3530/40ef506b-683b-40b4-9dfc-512b84137000:4320
[error.ts:11:4](https://webr.r-wasm.org/src/webR/error.ts)

Browser: Firefox 130.0.1 (64-bit) OS: Apple M2 Sequoia WebR: 0.4.2 rwasm: 0.2.0.9000

dipterix avatar Sep 22 '24 18:09 dipterix