Background
The current memory-driver persistence mechanism causes critical hidden failures on Vercel and other serverless function platforms:
- Default persistence chooses file-system adapter, which is not safe or persistent in a serverless environment.
- Read-only paths or short-lived instances lead to complete data loss.
- Data is not shared across concurrent function instances.
- Dirty-flag delayed write approach cannot guarantee consistency.
Impact
When deployed on serverless platforms like Vercel, all written data will be lost with no warning or error. All writable use cases are affected.
Fix recommendations
- Auto-detect runtime (serverless/edge/node/browser) in the driver. If serverless detected, disable file persistence and display prominent warning.
- Update documentation and schema docs to clearly warn about incompatibility in serverless context; instruct users to use
{ persistence: false } or supply custom adapter. - Add out-of-box config option for serverless-safe setup, providing hooks/samples for Upstash/KV adapters (hooks only, no implementation required).
- Ensure auto mode never triggers file-system adapter in serverless.
Suggested schedule
- P0: Complete runtime detection and warning + docs update.
- P1: Custom adapter config guidance.
PS: driver-turso should be a separate tracked task, not included in this patch.
Relevant code paths:
- packages/plugins/driver-memory/src/memory-driver.ts
- packages/plugins/driver-memory/src/persistence/file-adapter.ts
- packages/spec/src/data/driver/memory.zod.ts
Background
The current memory-driver persistence mechanism causes critical hidden failures on Vercel and other serverless function platforms:
Impact
When deployed on serverless platforms like Vercel, all written data will be lost with no warning or error. All writable use cases are affected.
Fix recommendations
{ persistence: false }or supply custom adapter.Suggested schedule
PS: driver-turso should be a separate tracked task, not included in this patch.
Relevant code paths: