Skip to content

exportFS

exportFS(server, channel): ExportHandle

Defined in: packages/runtime/src/container/proxy.ts:199

Expose a local Fileserver over a Channel.

Fileserver

Local fileserver to proxy.

Channel

Channel the client side will importFS() from.

ExportHandle

An ExportHandle — call dispose() to tear down.

The server-side proxy maintains an fd map translating integer proxy fds (issued monotonically as opens succeed) to the opaque server-side fd tokens. Reads transfer the result ArrayBuffer for zero-copy where the channel supports it. Errors are serialized as {ok: false, code, message} — plain objects cross the channel, FsError is reconstructed on the client side by importFS.

import { exportFS, importFS, createMemoryChannel } from '@fishnet/runtime/container/proxy'
import { memoryFS } from '@fishnet/core'
const [srvCh, cliCh] = createMemoryChannel()
const handle = exportFS(memoryFS(), srvCh) // server side
const proxy = importFS(cliCh) // client side
// ... use proxy as a Fileserver ...
proxy.disconnect()
handle.dispose()