Skip to content

AI Draft

All implemented via Bun-native APIs (no external deps at runtime):

CapabilityAPI
PasswordBun.password.hash() / .verify() — bcrypt
SQLitebun:sqlite — CRUD, prepared statements, WAL mode
FilesystemBun.file(), Bun.write() — streaming I/O
Globnew Bun.Glob().scan()
ServerBun.serve() — HTTP + WebSocket
Process safetySIGTERM/SIGINT handler with controlled fatal exit

bunRuntime(opts?) returns SlingshotRuntime. The factory validates and freezes the returned object. All capabilities are backed by Bun-native implementations — no polyfills or fallbacks.

  • WebSocket lifecycle callbacks are individually try-caught — no single handler crash takes down the server
  • publish() failures are caught and logged, never thrown
  • Process safety net is idempotent and detects test environments
  • Known Bun 1.3.11 bug: stop(true) never resolves after server-side ws.close() — handled via BUN_STOP_GRACE_MS race
  • password.verify() returns false for malformed hashes instead of throwing
  • src/index.tsbunRuntime() factory, all capability implementations
  • src/errors.tsBunRuntimeError, BunServerError, BunWebSocketError, BunSqliteError, BunPasswordError
  • src/testing.tscreateTestServer(), resetProcessSafetyNetForTest()