v0.7.0

Core Concepts

Last updated


HakoRun identifies functions by path, distinguishes versions by timestamp, and offers stored and immediate execution.

Function Paths


  • Each function is identified by the path string given at upload (e.g. math/add) and is called at /run/<path>.
  • A path containing .. is rejected at upload (HTTP 400).
  • Storage keys use the MD5 of path, not the raw string; see Storage.
  • Re-uploading a path replaces its language with the latest upload's.

Versions


BehaviorDescription
Version numberUnix seconds at upload time, returned as version by /upload
Default run/run/<path> without version runs the latest version
Pinned version/run/<path>?version=<timestamp>; a missing version returns 404
Non-integer versionTreated as absent; runs the latest version
Same-second uploadsTwo uploads to one path within a second share a version, and the later code overwrites the earlier

Stored Run vs Run-Now


ModeEndpointCode SourceLanguage Check
Stored runPOST /run/*pathStorage backend (body code/language are overwritten)At upload
Run-nowPOST /run-nowRequest body, never storedPer request; code must not be blank

Both modes share one execution path once the code is resolved:
graph LR
    Body[getRunBody capped by CODE_MAX_SIZE] --> Run[run]
    Run -->|stream=false| Once[runScript]
    Run -->|stream=true| SSE[runScriptWithSSE]
    Once --> Cmd[sandbox.SandboxCommand]
    SSE --> Cmd
    Cmd --> Wrapper[wrapper reads stdin]
  1. graph LR
  2. Body[getRunBody capped by CODE_MAX_SIZE] --> Run[run]
  3. Run -->|stream=false| Once[runScript]
  4. Run -->|stream=true| SSE[runScriptWithSSE]
  5. Once --> Cmd[sandbox.SandboxCommand]
  6. SSE --> Cmd
  7. Cmd --> Wrapper[wrapper reads stdin]

Execution Lifecycle


  • Every request starts a fresh sandboxed child process that exits when done; no state is shared.
  • The deadline is TIMEOUT_SCRIPT plus 5 seconds; the process is killed on timeout.
  • Non-stream mode responds once the process exits; stream mode pushes output while it runs, see Responses and SSE.


中文