@@ -947,6 +947,9 @@ export class InMemoryDriver implements DriverInterface {
947947 * - `K_SERVICE` — Google Cloud Run / Cloud Functions
948948 * - `FUNCTION_TARGET` — Google Cloud Functions (Node.js)
949949 * - `DENO_DEPLOYMENT_ID` — Deno Deploy
950+ *
951+ * Returns `false` when `process` or `process.env` is unavailable
952+ * (e.g. browser or edge runtimes without a Node.js process object).
950953 */
951954 private isServerlessEnvironment ( ) : boolean {
952955 if ( typeof globalThis . process === 'undefined' || ! globalThis . process . env ) {
@@ -965,6 +968,12 @@ export class InMemoryDriver implements DriverInterface {
965968 ) ;
966969 }
967970
971+ private static readonly SERVERLESS_PERSISTENCE_WARNING =
972+ 'Serverless environment detected — file-system persistence is disabled in auto mode. ' +
973+ 'Data will NOT be persisted across function invocations. ' +
974+ 'Set persistence: false to silence this warning, or provide a custom adapter ' +
975+ '(e.g. Upstash Redis, Vercel KV) via persistence: { adapter: yourAdapter }.' ;
976+
968977 /**
969978 * Initialize the persistence adapter based on configuration.
970979 * Defaults to 'auto' when persistence is not specified.
@@ -985,12 +994,7 @@ export class InMemoryDriver implements DriverInterface {
985994 this . persistenceAdapter = new LocalStoragePersistenceAdapter ( ) ;
986995 this . logger . debug ( 'Auto-detected browser environment, using localStorage persistence' ) ;
987996 } else if ( this . isServerlessEnvironment ( ) ) {
988- this . logger . warn (
989- 'Serverless environment detected — file-system persistence is disabled in auto mode. ' +
990- 'Data will NOT be persisted across function invocations. ' +
991- 'Set persistence: false to silence this warning, or provide a custom adapter ' +
992- '(e.g. Upstash Redis, Vercel KV) via persistence: { adapter: yourAdapter }.'
993- ) ;
997+ this . logger . warn ( InMemoryDriver . SERVERLESS_PERSISTENCE_WARNING ) ;
994998 } else {
995999 const { FileSystemPersistenceAdapter } = await import ( './persistence/file-adapter.js' ) ;
9961000 this . persistenceAdapter = new FileSystemPersistenceAdapter ( ) ;
@@ -1016,12 +1020,7 @@ export class InMemoryDriver implements DriverInterface {
10161020 } ) ;
10171021 this . logger . debug ( 'Auto-detected browser environment, using localStorage persistence' ) ;
10181022 } else if ( this . isServerlessEnvironment ( ) ) {
1019- this . logger . warn (
1020- 'Serverless environment detected — file-system persistence is disabled in auto mode. ' +
1021- 'Data will NOT be persisted across function invocations. ' +
1022- 'Set persistence: false to silence this warning, or provide a custom adapter ' +
1023- '(e.g. Upstash Redis, Vercel KV) via persistence: { adapter: yourAdapter }.'
1024- ) ;
1023+ this . logger . warn ( InMemoryDriver . SERVERLESS_PERSISTENCE_WARNING ) ;
10251024 } else {
10261025 const { FileSystemPersistenceAdapter } = await import ( './persistence/file-adapter.js' ) ;
10271026 this . persistenceAdapter = new FileSystemPersistenceAdapter ( {
0 commit comments