Skip to content

fix(service-cloud): tmpdir fallback for default data dir on read-only serverless filesystems#1233

Merged
hotlong merged 3 commits into
mainfrom
copilot/fix-webcrypto-missing-export
May 8, 2026
Merged

fix(service-cloud): tmpdir fallback for default data dir on read-only serverless filesystems#1233
hotlong merged 3 commits into
mainfrom
copilot/fix-webcrypto-missing-export

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 8, 2026

  • Fix webcrypto missing export in studio node polyfill (Vercel studio build)
  • Fix ENOENT: mkdir '/var/task/.objectstack' cold-start failure on Vercel/Lambda
    • Replace silent /tmp SQLite fallback with fail-fast error pointing at TURSO_DATABASE_URL (Turso is the default ObjectStack pairing for serverless; ephemeral /tmp would silently corrupt data across cold starts)
    • resolveDefaultDataDir() throws on Vercel/Lambda/Netlify when OS_DATA_DIR is unset
    • cloud-stack.ts control-driver default made lazy so TURSO_DATABASE_URL / OS_CONTROL_DATABASE_URL short-circuit it
    • 15 unit tests cover precedence, throw conditions, and error-message contents
    • pnpm build green (51/51 tasks)
    • CHANGELOG entry updated

Copilot AI and others added 2 commits May 7, 2026 23:58
The studio Vite build aliases 'crypto' to mocks/node-polyfills.ts.
@objectstack/runtime imports `webcrypto` from 'crypto', so the polyfill
must export it. Map webcrypto to globalThis.crypto (Web Crypto API)
which provides the same SubtleCrypto/getRandomValues surface in browsers.

Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/49abf5ad-ca45-4ce6-b799-657ad8f2cd69

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
apps/cloud booted on Vercel was failing with "ENOENT: no such file or
directory, mkdir '/var/task/.objectstack'" because cloud-stack /
runtime-stack / project-kernel-factory / environment-registry /
artifact-environment-registry all hard-coded
`<cwd>/.objectstack/data` for the default SQLite control DB and
InMemoryDriver per-project JSON paths. /var/task on Vercel (and
analogous bundle roots on AWS Lambda / Netlify) is read-only.

Centralise the resolution in a new resolveDefaultDataDir() helper that:
  1. Honours OS_DATA_DIR.
  2. Defaults to <cwd>/.objectstack/data on writable filesystems.
  3. Falls back to <os.tmpdir()>/.objectstack/data on Vercel /
     AWS_LAMBDA_FUNCTION_NAME / NETLIFY (or OS_READONLY_FS=1) with a
     one-time warning advising users to configure
     OS_CONTROL_DATABASE_URL for production.

12 new unit tests cover the precedence and serverless detection.
CHANGELOG updated.

Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/d91ac991-ce21-4bce-a544-d2053fd5f8a5

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectstack-cloud Ready Ready Preview, Comment May 8, 2026 0:35am
objectstack-objectos Ready Ready Preview, Comment May 8, 2026 0:35am
spec Ready Ready Preview, Comment May 8, 2026 0:35am

Request Review

…allback

Replace the ephemeral /tmp SQLite fallback (introduced in 5833df4) with a
fail-fast error on serverless platforms. /tmp on Vercel/Lambda/Netlify is
per-instance and ephemeral — SQLite there silently corrupts data across
concurrent cold starts. The correct default for Vercel is Turso (libSQL),
which ObjectStack already supports as the natural serverless pairing.

Behaviour:
  - resolveDefaultDataDir() throws on serverless (Vercel / AWS Lambda /
    Netlify / OS_READONLY_FS=1) unless OS_DATA_DIR is set, with an error
    message naming TURSO_DATABASE_URL, TURSO_AUTH_TOKEN,
    OS_CONTROL_DATABASE_URL, and OS_DATA_DIR (escape hatch for EFS /
    mounted volumes).
  - cloud-stack.ts evaluates the file-backed default lazily so any of
    OS_CONTROL_DATABASE_URL / OS_DATABASE_URL / TURSO_DATABASE_URL
    short-circuit it (Vercel deployments configured with Turso boot
    cleanly).
  - On writable filesystems (objectstack dev / serve, Docker, bare metal)
    the existing <cwd>/.objectstack/data behaviour is preserved.

Tests rewritten (15 cases) to assert throw-on-serverless and error
message contents. CHANGELOG entry updated.

Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/9969986e-eb1d-4d25-b31b-75fb22429b04

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
@hotlong hotlong marked this pull request as ready for review May 8, 2026 01:03
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests labels May 8, 2026
@hotlong hotlong merged commit ea10e85 into main May 8, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants