vmware-labs / wasm-workers-server

🚀 Develop and run serverless applications on WebAssembly

Home Page:https://workers.wasmlabs.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JavaScript workers are not properly working on Windows

Angelmmiguel opened this issue · comments

Describe the bug

After adding a new end-to-end test suite on #134, the CI failed for JavaScript workers on Windows. I could reproduce the issue on a Windows machine and I'm researching the root cause now.

Reproduction steps

  1. Download the latest version of wws
  2. Download a basic JavaScript worker from the examples folder
  3. Run it
  4. Get a 503 error

Expected behavior

The workers returns the expected 200 response.

Additional context

Rust workers are working properly.

After an initial research, I found a "5, Access Denied" error when trying to open the folder that includes the worker source code in Windows. Note that for interpreted language workers like JavaScript, wws relies on saving the source code into a temporary folder that will mount later.

In the case of JavaScript, this is the specific method that opens it:

fn prepare_wasi_ctx(&self, builder: WasiCtxBuilder) -> Result<WasiCtxBuilder> {
let source = fs::File::open(&self.store.folder)?;
Ok(builder.preopened_dir(Dir::from_std_file(source), "/src")?)
}

I need now to research why wws cannot open the folder that was created by the same process before.

Finally, the issue relied on the differences when opening a directory using fs::File. This is a valid operation in Unix, while failing with AccessDenied error in Windows. A lesson learned here is that we cannot rely on fs::File for working with directories.