You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(service-cloud): require Turso on Vercel — no silent /tmp SQLite fallback
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>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
## [Unreleased]
9
9
10
10
### Fixed
11
-
- **Cold-start `ENOENT: mkdir '/var/task/.objectstack'` on Vercel/Lambda** (`@objectstack/service-cloud`) — `createCloudStack()`, `createRuntimeStack()`, `DefaultProjectKernelFactory`, `DefaultEnvironmentDriverRegistry`, and `ArtifactEnvironmentDriverRegistry` previously hard-coded the SQLite/InMemoryDriver default data directory to `<process.cwd()>/.objectstack/data`. On serverless platforms the bundle root is read-only, which made `apps/cloud` fail to boot whenever no explicit `OS_CONTROL_DATABASE_URL` was configured. Centralised the resolution in a new `resolveDefaultDataDir()` helper that honours `OS_DATA_DIR`, then falls back to `<cwd>/.objectstack/data` on writable filesystems and `<os.tmpdir()>/.objectstack/data` (with a one-time warning) on Vercel / AWS Lambda / Netlify (or any environment where `OS_READONLY_FS=1`). Production deployments must still configure a persistent database; this only restores cold-start safety so the warning surfaces instead of an opaque `ENOENT`. Helper covered by 12 new unit tests in `packages/services/service-cloud/test/data-dir.test.ts`.
11
+
- **Cold-start `ENOENT: mkdir '/var/task/.objectstack'` on Vercel/Lambda** (`@objectstack/service-cloud`) — `createCloudStack()`, `createRuntimeStack()`, `DefaultProjectKernelFactory`, `DefaultEnvironmentDriverRegistry`, and `ArtifactEnvironmentDriverRegistry` previously hard-coded the SQLite/InMemoryDriver default data directory to `<process.cwd()>/.objectstack/data`. On serverless platforms (Vercel `/var/task`, AWS Lambda, Netlify) the bundle root is read-only, so `apps/cloud` failed to boot whenever no explicit persistent DB URL was configured. Centralised the resolution in a new `resolveDefaultDataDir()` helper (`packages/services/service-cloud/src/data-dir.ts`) that honours `OS_DATA_DIR`, returns `<cwd>/.objectstack/data` on writable filesystems, and **throws a fail-fast error on serverless** pointing at `TURSO_DATABASE_URL` (recommended on Vercel — Turso is the default ObjectStack pairing for serverless), `OS_CONTROL_DATABASE_URL`, and `OS_DATA_DIR` (escape hatch for EFS / mounted volumes). File-backed SQLite on serverless `/tmp` is rejected by design because `/tmp` is per-instance and ephemeral, which silently corrupts data across concurrent invocations. The `cloud-stack` control-driver default is now lazy so deployments that set `TURSO_DATABASE_URL` never hit the throw. 15 unit tests cover the precedence, error message contents, and platform detection in `test/data-dir.test.ts`.
12
12
-**`@objectstack/studio` Vercel build: `webcrypto` not exported by `mocks/node-polyfills.ts`** — `@objectstack/runtime` imports `webcrypto` from `crypto`, but the studio Vite alias swaps `crypto` for the local node polyfill which did not export it. Added a `webcrypto` shim that proxies to `globalThis.crypto`, restoring the rolldown build.
13
13
-**`@objectstack/driver-sql` tests failing in CI** — Added `vitest.config.ts` with resolve aliases for `@objectstack/spec/*` subpath exports (`/data`, `/contracts`, `/system`). Without these aliases, vitest could not resolve the source paths at test time, causing all 81 tests to fail with `ERR_MODULE_NOT_FOUND`.
14
14
-**RLS fail-open across tenants** (`@objectstack/plugin-security`) — A logged-in user with no active organization (e.g. immediately after sign-up, before joining or creating one) was previously seeing every tenant's data on `account`, `sys_member`, `sys_organization`, etc. Multiple compounding bugs were responsible:
0 commit comments