Skip to content

@lastshotlabs/slingshot-runtime-edge

npm install @lastshotlabs/slingshot-runtime-edge

Replace the runtime’s structured logger. Pass null to reset to the default JSON console logger. Returns the previous logger so tests can save and restore state.

function configureRuntimeEdgeLogger(logger: Logger | null): Logger

Source: packages/runtime-edge/src/index.ts

Create a SlingshotRuntime implementation for edge runtimes.

Provides runtime capabilities compatible with Cloudflare Workers and Deno Deploy. Uses the Web Crypto API for password hashing — no native modules, no Node.js built-ins.

Limitations vs. Bun/Node runtimes:

  • supportsAsyncLocalStorage is false. Use explicit context passing instead of AsyncLocalStorage for per-request state propagation.
  • SQLite is not supported. Use a cloud database instead.
  • HTTP server factory (runtime.server.listen()) is not callable. Export a fetch handler from your Worker entry module.
  • Glob scanning is not supported. Route discovery must happen at build time.
  • Filesystem writes are not supported. Use KV, R2, or another storage service.
  • readFile() always returns null unless fileStore is provided.
  • No process lifecycle hooks (SIGTERM/SIGINT). Edge isolates are started and stopped by the platform; the runtime does not expose a process.on('SIGTERM') equivalent. Cleanup should happen at the worker level via platform hooks (e.g., Cloudflare’s ctx.waitUntil).

Timeout behaviour:

  • fileStoreTimeoutMs uses an AbortController-backed timeout. When the deadline fires, the controller is aborted and callers who accept the optional AbortSignal parameter can cancel their underlying work.
  • heartbeatTimeoutMs wraps long-running operations with a global timeout guard (see EdgeRuntimeOptions.heartbeatTimeoutMs).

For a complete capability matrix see runtimeCapabilities.

function edgeRuntime(options: EdgeRuntimeOptions = {}): SlingshotRuntime

Source: packages/runtime-edge/src/index.ts

Return a frozen capability descriptor for the edge runtime platform.

This is a static report — it always describes what the edge platform can and cannot do, independent of any particular edgeRuntime() configuration.

function runtimeCapabilities(): EdgeRuntimeCapabilities

Source: packages/runtime-edge/src/index.ts

Raised when the edge runtime cannot read a configured static file.

Source: packages/runtime-edge/src/errors.ts

Raised when an edge runtime file read exceeds the configured byte limit.

Source: packages/runtime-edge/src/errors.ts

Raised when edge password hashing and verification hooks are configured inconsistently.

Source: packages/runtime-edge/src/errors.ts

Errors thrown by the Edge runtime implementation.

Source: packages/runtime-edge/src/errors.ts

Raised when code requests a runtime feature that edge isolates do not support.

Source: packages/runtime-edge/src/errors.ts

Programmatic capability report for the edge runtime platform.

Consumers can use this to feature-detect at runtime without needing to instantiate a full runtime or catch errors from stubs.

All boolean capabilities reflect what the platform itself supports (not what an individual edgeRuntime() caller configured). For example, filesystem.read is always false because edge runtimes have no local filesystem — even when fileStore is configured, reads go through the network, not the local FS.

Source: packages/runtime-edge/src/index.ts

Options for edgeRuntime().

Source: packages/runtime-edge/src/index.ts

Streaming descriptor returned by fileStore.

Allows readFile() to enforce maxFileBytes without buffering the entire payload first. If size is supplied (e.g. from a HEAD response or stat), the runtime rejects oversized files before reading any bytes. Otherwise it pulls chunks from stream and aborts as soon as the running byte count exceeds the cap.

Source: packages/runtime-edge/src/index.ts

Result returned by a fileStore lookup.

  • string: a fully buffered UTF-8 payload. Suitable for small bundled assets where the size is known to be safe.
  • FileStoreStream: a streaming descriptor with optional declared size. Required for any source that may return large files; the runtime will honour maxFileBytes before fully buffering.
  • null: file not found.

Source: packages/runtime-edge/src/index.ts