File tree Expand file tree Collapse file tree 1 file changed +26
-6
lines changed
packages/db/src/impl/pouch Expand file tree Collapse file tree 1 file changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -27,12 +27,32 @@ export class PouchDataLayerProvider implements DataLayerProvider {
2727 async initialize ( ) : Promise < void > {
2828 if ( this . initialized ) return ;
2929
30- // Get the current username from session
31- this . currentUsername = await getLoggedInUsername ( ) ;
32-
33- // Create the user db instance
34- if ( this . currentUsername ) {
35- this . userDB = await User . instance ( this . currentUsername ) ;
30+ // Check if we are in a Node.js environment
31+ const isNodeEnvironment =
32+ typeof process !== 'undefined' && process . versions != null && process . versions . node != null ;
33+
34+ if ( isNodeEnvironment ) {
35+ console . log (
36+ 'PouchDataLayerProvider: Running in Node.js environment, skipping user session check and user DB initialization.'
37+ ) ;
38+ } else {
39+ // Assume browser-like environment, proceed with user session logic
40+ try {
41+ // Get the current username from session
42+ this . currentUsername = await getLoggedInUsername ( ) ;
43+
44+ // Create the user db instance if a username was found
45+ if ( this . currentUsername ) {
46+ this . userDB = await User . instance ( this . currentUsername ) ;
47+ } else {
48+ console . warn ( 'PouchDataLayerProvider: No logged-in username found in session.' ) ;
49+ }
50+ } catch ( error ) {
51+ console . error (
52+ 'PouchDataLayerProvider: Error during user session check or user DB initialization:' ,
53+ error
54+ ) ;
55+ }
3656 }
3757
3858 this . initialized = true ;
You can’t perform that action at this time.
0 commit comments