fix(service-cloud): tmpdir fallback for default data dir on read-only serverless filesystems#1233
Merged
Merged
Conversation
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>
Copilot created this pull request from a session on behalf of
hotlong
May 8, 2026 00:15
View session
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…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
approved these changes
May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
webcryptomissing export in studio node polyfill (Vercel studio build)ENOENT: mkdir '/var/task/.objectstack'cold-start failure on Vercel/Lambda/tmpSQLite fallback with fail-fast error pointing atTURSO_DATABASE_URL(Turso is the default ObjectStack pairing for serverless; ephemeral/tmpwould silently corrupt data across cold starts)resolveDefaultDataDir()throws on Vercel/Lambda/Netlify whenOS_DATA_DIRis unsetcloud-stack.tscontrol-driver default made lazy soTURSO_DATABASE_URL/OS_CONTROL_DATABASE_URLshort-circuit itpnpm buildgreen (51/51 tasks)