-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lazy loading in backend environment? (Deno) #69
Comments
I'm not completely sure - the createLazyFile function seems to have been written specifically for the browser context, as it uses You might be able to use this shim library to get it to work: https://www.npmjs.com/package/xmlhttprequest |
That could work. Do you have an idea on how to patch it as I don't think the FS comes bundled with this lib right? |
deno apparently has a solution for xhr, and I was able to get past your first error: > let xhr = await import("https://deno.land/x/xhr@0.3.1/mod.ts")
undefined
> try {
const Modules = await h5wasm.ready;
const { FS } = Modules;
FS.createLazyFile("/", "current.h5", signedUrl, true, false);
const file = new h5wasm.File("current.h5");
console.log(file);
} catch (err) {
console.error(err);
}
Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc
undefined More investigation required... I don't know the current status of web workers in Deno. |
Hm yeah it gets through until your error. Deno has built in support for web workers, but it does not seem to make a difference when using those. I am trying to see if I can get something to work as well. // main.ts
const worker = new Worker(
new URL("./worker.ts", import.meta.url).href,
{
type: "module",
},
);
worker.postMessage({ example: 'hello world' }); // worker.ts
self.onmessage = async (e) => {
const Modules = await h5wasm.ready;
const { FS } = Modules;
FS.createLazyFile("/", "current.h5", signedUrl, true, false);
// ^ results in the same error
const file = new h5wasm.File("current.h5");
self.close();
}; |
It looks like Deno doesn't support synchronous fetch/xhr even in a web worker. I think the sync flag is required for the createLazyFile implementation in Emscripten, and it's the test for that flag that is failing and throwing the current error. I don't see any way to do a synchronous fetch in Deno, and I don't see any way to do an async file read in HDF5 (without writing a new Virtual File Driver), so I'm not sure if there's an easy path forward. If you find something, please let me know! |
Nevermind it has the same issue :/ |
Well, there seems to be an interesting difference in the way dependencies are handled in Deno. For example importing By the way, I don't know if this makes sense for the lib, but also publishing on JSR might simplify the build flow for different runtimes. I am not sure since I have never used any lib from jsr but it seems cool. |
Thanks for the tip... I'll check out JSR. |
Is it possible the |
Yeah that seems like it, but I can't figure out how to change it. I've worked on another solution using some nodejs serverless functions to handle this as a service. |
I have a backend server where I want to lazy load a dataset to limit my bandwidth usage. Based on #4 I tried to implement it like so:
My file is stored in a s3 compatible storage bucket with range request supported, but this doesn't seem to work as I get:
I think my environment is not setup properly as it is not web-based. Is there anything else needed to configure lazy url based access in Deno (and Node)?
The text was updated successfully, but these errors were encountered: