@cloudflare/workers-wasi
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

Workers WASI

Work in progress

An experimental implementation of the WebAssembly System Interface designed to run on Cloudflare Workers

Usage

import { WASI } from '@cloudflare/workers-wasi';
import mywasm from './mywasm.wasm';

const wasi = new WASI();
const instance = new WebAssembly.Instance(mywasm, {
   wasi_snapshot_preview1: wasi.wasiImport
});

await wasi.start(instance);

Development

Install Rust and nvm then run

nvm use --lts

Build and test

git clone --recursive git@github.com:cloudflare/workers-wasi.git
cd ./workers-wasi
make -j test

Build with Docker

git clone --recursive git@github.com:cloudflare/workers-wasi.git
cd ./workers-wasi
cat ./Dockerfile | docker build -t workers-wasi-build -
docker run --rm -it -v $(pwd):/workers-wasi workers-wasi-build

Testing

We aim to be interchangeable with other WASI implementations. Integration tests are run locally using Miniflare against the following test suites:

Notes

An ephemeral filesystem implementation built on littlefs is included. Both soft and hard links are not yet supported.

The following syscalls are not yet supported and return ENOSYS

  • fd_readdir
  • path_link
  • path_readlink
  • path_symlink
  • poll_oneoff
  • sock_recv
  • sock_send
  • sock_shutdown

Timestamps are captured using Date.now() which has unique behavior on the Workers platform for security reasons. This affects the implementation of

  • clock_res_get
  • clock_time_get
  • fd_filestat_set_times
  • path_filestat_set_times

TODO (remove)

Misc TODO:

  • [ ] path_rename (update old path for existing open fds)
  • [ ] fix preopens interface (use object), and update options docs
  • [ ] document difference between nodejs options and ours (streams/fs)
  • [ ] fd_close (stdio)
  • [ ] fd_renumber (stdio)
  • [ ] fd_read/fd_write does not work with renumbering stdio
  • [ ] update file timestamps appropriately

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.5894latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.5894
0.0.41
0.0.22
0.0.11

Package Sidebar

Install

npm i @cloudflare/workers-wasi

Weekly Downloads

898

Version

0.0.5

License

BSD-3-Clause

Unpacked Size

246 kB

Total Files

20

Last publish

Collaborators

  • lerwincf
  • lbarthonet
  • cf-media-manager
  • jacobbednarz
  • celso
  • cf-radar
  • dash_service_account
  • g4brym
  • snigdha34
  • wrangler-publisher
  • marksteyn
  • chiminator
  • sgoodhew_cf
  • terinjokes
  • third774
  • jsteinberger
  • jasnell
  • asapzacy
  • pcostanzo
  • gregbrimble
  • geelen
  • rexscaria
  • dcruz_cf
  • xuranwang
  • jculvey
  • sejoker
  • vasturiano
  • cf-ci-write
  • segments-write
  • thibmeu
  • xortive
  • gurjinder
  • cf-ci2
  • lvalenta
  • worenga