I have a minimal webpage in site-content/index.html with
<script type='module'>
import { openFile, draw } from 'https://root.cern/js/latest/modules/main.mjs';
let file = await openFile('example.root');
</script>
I have example.root in the same folder. It is 77MB. I have not problem to open it in ROOT. I get the following error
First block is 1024 bytes but browser does not provides access to header - try to read full file
Try to load very large file 80562913 at once - abort
Fail to load url example.root?stamp=1716326372479
Try to load very large file 80562913 at once - abort
Fail to load url example.root
Uncaught Error: Fail to read with several ranges
at XMLHttpRequest.read_callback (io.mjs:2830:31)
at XMLHttpRequest.<anonymous> (core.mjs:890:140)
at xhr.onreadystatechange (core.mjs:937:28)
at XMLHttpRequest.<anonymous> (io.mjs:2758:26)
I tried with different web server with the same results.
livepreview from vscode
python -m http.server 8080
docker run -it --rm -p 8080:80 --name web -v ./site-content:/usr/share/nginx/html nginx
I tried with Google Chrome and Firefox. This is the log from nginx
if (res && first_req) {
if (file.fAcceptRanges && !first_req.getResponseHeader('Accept-Ranges')) {
file.fAcceptRanges = false;
if (res?.byteLength === place[1]) {
// special case with cernbox, let try to get full size content
console.warn(`First block is ${place[1]} bytes but browser does not provides access to header - try to read full file`);
first_block_retry = true;
return send_new_request();
}
}
Actually check in the jsroot code was due to other problem. In some cases browser just block access to any http header making impossible to handle partial requests. I will try to improve it.
Thank you very much for your prompt reply. It works!
It works with nginx and apache.
Not working python python -m http.server
Not working in vscode live preview
Maybe these last two are too limited. I get
___vscode_liveprevie…injected_script:141 Server response size 80562913 larger than expected 11000000. Abort I/O operation
___vscode_liveprevie…injected_script:141 Try to load very large file 80562913 at once - abort
Fail to load url example.root
This is known problem - it does not support multi-range requests.
The only chance to use it - provide settings.MaxRanges = 1 before loading first file.
I have workaround in JSROOT code (for my testing) - but it only activated when firefox browser is used.
Not working in vscode live preview
Looks like vscode does not support ranges requests at all - and jsroot makes failure when reading more than 50MB at once.