Skip to content

importFS

importFS(channel): Fileserver & object

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

Create a local Fileserver backed by a remote exportFS over a Channel.

Channel

Channel the remote exportFS is listening on.

Fileserver & object

A fileserver (+ disconnect()) whose methods proxy as request/response messages.

All ten Fileserver methods are proxied. Errors are reconstructed as FsError from the response code / message, so callers see the same shape as a local server. disconnect() rejects all pending calls with EPIPE and fails future calls the same way — idempotent.

import { exportFS, importFS, createMemoryChannel } from '@fishnet/runtime/container/proxy'
import { memoryFS } from '@fishnet/core'
const [srvCh, cliCh] = createMemoryChannel()
const handle = exportFS(memoryFS(), srvCh)
const proxy = importFS(cliCh)
await proxy.mkdir('/tmp' as InnerPath)
proxy.disconnect()
handle.dispose()