mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-23 06:58:19 +02:00
Merge pull request #185 from R0m1k3/1.1
Refine database connections and handle potential errors during startup
This commit is contained in:
2 files changed
+265
-11
No files matched your search
+238
@@ -0,0 +1,238 @@
|
|||||||
|
|
||||||
|
|
||||||
|
User-related
|
||||||
|
|
||||||
|
|
||||||
|
Environment-related
|
||||||
|
|
||||||
|
Registries
|
||||||
|
|
||||||
|
Logs
|
||||||
|
|
||||||
|
Notifications
|
||||||
|
|
||||||
|
Settings
|
||||||
|
|
||||||
|
New version available 2.27.9
|
||||||
|
DismissSee what's new
|
||||||
|
Community Edition
|
||||||
|
2.27.6 LTS
|
||||||
|
Containers>logiflow-logiflow-1>Logs
|
||||||
|
Container logs
|
||||||
|
|
||||||
|
|
||||||
|
admin
|
||||||
|
Log viewer settings
|
||||||
|
Auto-refresh logs
|
||||||
|
Wrap lines
|
||||||
|
Display timestamps
|
||||||
|
Fetch
|
||||||
|
All logs
|
||||||
|
Search
|
||||||
|
Filter...
|
||||||
|
Lines
|
||||||
|
100
|
||||||
|
Actions
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
at authenticate (/app/node_modules/passport/lib/middleware/authenticate.js:379:7)
|
||||||
|
|
||||||
|
at file:///app/dist/index.js:4874:7
|
||||||
|
|
||||||
|
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
|
||||||
|
|
||||||
|
at next (/app/node_modules/express/lib/router/route.js:149:13)
|
||||||
|
|
||||||
|
at Route.dispatch (/app/node_modules/express/lib/router/route.js:119:3)
|
||||||
|
|
||||||
|
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
POST /api/login 500 in 2ms
|
||||||
|
|
||||||
|
TypeError: Cannot read properties of null (reading 'select')
|
||||||
|
|
||||||
|
at DatabaseStorage.getUserByUsername (file:///app/dist/index.js:1204:33)
|
||||||
|
|
||||||
|
at Strategy._verify (file:///app/dist/index.js:4832:38)
|
||||||
|
|
||||||
|
at Strategy.authenticate (/app/node_modules/passport-local/lib/strategy.js:90:12)
|
||||||
|
|
||||||
|
at attempt (/app/node_modules/passport/lib/middleware/authenticate.js:378:16)
|
||||||
|
|
||||||
|
at authenticate (/app/node_modules/passport/lib/middleware/authenticate.js:379:7)
|
||||||
|
|
||||||
|
at file:///app/dist/index.js:4874:7
|
||||||
|
|
||||||
|
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
|
||||||
|
|
||||||
|
at next (/app/node_modules/express/lib/router/route.js:149:13)
|
||||||
|
|
||||||
|
at Route.dispatch (/app/node_modules/express/lib/router/route.js:119:3)
|
||||||
|
|
||||||
|
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
|
||||||
|
|
||||||
|
Server error: {
|
||||||
|
|
||||||
|
status: 500,
|
||||||
|
|
||||||
|
message: "Cannot read properties of null (reading 'select')",
|
||||||
|
|
||||||
|
error: TypeError: Cannot read properties of null (reading 'select')
|
||||||
|
|
||||||
|
at DatabaseStorage.getUserByUsername (file:///app/dist/index.js:1204:33)
|
||||||
|
|
||||||
|
at Strategy._verify (file:///app/dist/index.js:4832:38)
|
||||||
|
|
||||||
|
at Strategy.authenticate (/app/node_modules/passport-local/lib/strategy.js:90:12)
|
||||||
|
|
||||||
|
at attempt (/app/node_modules/passport/lib/middleware/authenticate.js:378:16)
|
||||||
|
|
||||||
|
at authenticate (/app/node_modules/passport/lib/middleware/authenticate.js:379:7)
|
||||||
|
|
||||||
|
at file:///app/dist/index.js:4874:7
|
||||||
|
|
||||||
|
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
|
||||||
|
|
||||||
|
at next (/app/node_modules/express/lib/router/route.js:149:13)
|
||||||
|
|
||||||
|
at Route.dispatch (/app/node_modules/express/lib/router/route.js:119:3)
|
||||||
|
|
||||||
|
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
POST /api/login 500 in 2ms
|
||||||
|
|
||||||
|
TypeError: Cannot read properties of null (reading 'select')
|
||||||
|
|
||||||
|
at DatabaseStorage.getUserByUsername (file:///app/dist/index.js:1204:33)
|
||||||
|
|
||||||
|
at Strategy._verify (file:///app/dist/index.js:4832:38)
|
||||||
|
|
||||||
|
at Strategy.authenticate (/app/node_modules/passport-local/lib/strategy.js:90:12)
|
||||||
|
|
||||||
|
at attempt (/app/node_modules/passport/lib/middleware/authenticate.js:378:16)
|
||||||
|
|
||||||
|
at authenticate (/app/node_modules/passport/lib/middleware/authenticate.js:379:7)
|
||||||
|
|
||||||
|
at file:///app/dist/index.js:4874:7
|
||||||
|
|
||||||
|
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
|
||||||
|
|
||||||
|
at next (/app/node_modules/express/lib/router/route.js:149:13)
|
||||||
|
|
||||||
|
at Route.dispatch (/app/node_modules/express/lib/router/route.js:119:3)
|
||||||
|
|
||||||
|
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
|
||||||
|
|
||||||
|
Server error: {
|
||||||
|
|
||||||
|
status: 500,
|
||||||
|
|
||||||
|
message: "Cannot read properties of null (reading 'select')",
|
||||||
|
|
||||||
|
error: TypeError: Cannot read properties of null (reading 'select')
|
||||||
|
|
||||||
|
at DatabaseStorage.getUserByUsername (file:///app/dist/index.js:1204:33)
|
||||||
|
|
||||||
|
at Strategy._verify (file:///app/dist/index.js:4832:38)
|
||||||
|
|
||||||
|
at Strategy.authenticate (/app/node_modules/passport-local/lib/strategy.js:90:12)
|
||||||
|
|
||||||
|
at attempt (/app/node_modules/passport/lib/middleware/authenticate.js:378:16)
|
||||||
|
|
||||||
|
at authenticate (/app/node_modules/passport/lib/middleware/authenticate.js:379:7)
|
||||||
|
|
||||||
|
at file:///app/dist/index.js:4874:7
|
||||||
|
|
||||||
|
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
|
||||||
|
|
||||||
|
at next (/app/node_modules/express/lib/router/route.js:149:13)
|
||||||
|
|
||||||
|
at Route.dispatch (/app/node_modules/express/lib/router/route.js:119:3)
|
||||||
|
|
||||||
|
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
POST /api/login 500 in 2ms
|
||||||
|
|
||||||
|
TypeError: Cannot read properties of null (reading 'select')
|
||||||
|
|
||||||
|
at DatabaseStorage.getUserByUsername (file:///app/dist/index.js:1204:33)
|
||||||
|
|
||||||
|
at Strategy._verify (file:///app/dist/index.js:4832:38)
|
||||||
|
|
||||||
|
at Strategy.authenticate (/app/node_modules/passport-local/lib/strategy.js:90:12)
|
||||||
|
|
||||||
|
at attempt (/app/node_modules/passport/lib/middleware/authenticate.js:378:16)
|
||||||
|
|
||||||
|
at authenticate (/app/node_modules/passport/lib/middleware/authenticate.js:379:7)
|
||||||
|
|
||||||
|
at file:///app/dist/index.js:4874:7
|
||||||
|
|
||||||
|
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
|
||||||
|
|
||||||
|
at next (/app/node_modules/express/lib/router/route.js:149:13)
|
||||||
|
|
||||||
|
at Route.dispatch (/app/node_modules/express/lib/router/route.js:119:3)
|
||||||
|
|
||||||
|
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
|
||||||
|
|
||||||
|
Server error: {
|
||||||
|
|
||||||
|
status: 500,
|
||||||
|
|
||||||
|
message: "Cannot read properties of null (reading 'select')",
|
||||||
|
|
||||||
|
error: TypeError: Cannot read properties of null (reading 'select')
|
||||||
|
|
||||||
|
at DatabaseStorage.getUserByUsername (file:///app/dist/index.js:1204:33)
|
||||||
|
|
||||||
|
at Strategy._verify (file:///app/dist/index.js:4832:38)
|
||||||
|
|
||||||
|
at Strategy.authenticate (/app/node_modules/passport-local/lib/strategy.js:90:12)
|
||||||
|
|
||||||
|
at attempt (/app/node_modules/passport/lib/middleware/authenticate.js:378:16)
|
||||||
|
|
||||||
|
at authenticate (/app/node_modules/passport/lib/middleware/authenticate.js:379:7)
|
||||||
|
|
||||||
|
at file:///app/dist/index.js:4874:7
|
||||||
|
|
||||||
|
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
|
||||||
|
|
||||||
|
at next (/app/node_modules/express/lib/router/route.js:149:13)
|
||||||
|
|
||||||
|
at Route.dispatch (/app/node_modules/express/lib/router/route.js:119:3)
|
||||||
|
|
||||||
|
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
POST /api/login 500 in 2ms
|
||||||
|
|
||||||
|
TypeError: Cannot read properties of null (reading 'select')
|
||||||
|
|
||||||
|
at DatabaseStorage.getUserByUsername (file:///app/dist/index.js:1204:33)
|
||||||
|
|
||||||
|
at Strategy._verify (file:///app/dist/index.js:4832:38)
|
||||||
|
|
||||||
|
at Strategy.authenticate (/app/node_modules/passport-local/lib/strategy.js:90:12)
|
||||||
|
|
||||||
|
at attempt (/app/node_modules/passport/lib/middleware/authenticate.js:378:16)
|
||||||
|
|
||||||
|
at authenticate (/app/node_modules/passport/lib/middleware/authenticate.js:379:7)
|
||||||
|
|
||||||
|
at file:///app/dist/index.js:4874:7
|
||||||
|
|
||||||
|
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
|
||||||
|
|
||||||
|
at next (/app/node_modules/express/lib/router/route.js:149:13)
|
||||||
|
|
||||||
|
at Route.dispatch (/app/node_modules/express/lib/router/route.js:119:3)
|
||||||
|
|
||||||
|
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
|
||||||
+27
-11
@@ -14,15 +14,15 @@ console.log('🔗 Database initialization:', {
|
|||||||
let db: any;
|
let db: any;
|
||||||
let pool: any;
|
let pool: any;
|
||||||
|
|
||||||
if (dbUrl && (isProduction || process.env.FORCE_POSTGRES === 'true')) {
|
if (isProduction && dbUrl && (dbUrl.includes('logiflow-db') || dbUrl.includes('localhost') || dbUrl.includes('127.0.0.1'))) {
|
||||||
// Use PostgreSQL for production or when forced
|
// Standard PostgreSQL for production Docker
|
||||||
console.log('🐘 Using PostgreSQL database');
|
console.log('🐳 PRODUCTION: Using standard PostgreSQL');
|
||||||
const { Pool } = await import('pg');
|
const { Pool } = await import('pg');
|
||||||
const { drizzle } = await import('drizzle-orm/node-postgres');
|
const { drizzle } = await import('drizzle-orm/node-postgres');
|
||||||
|
|
||||||
pool = new Pool({
|
pool = new Pool({
|
||||||
connectionString: dbUrl,
|
connectionString: dbUrl,
|
||||||
ssl: dbUrl.includes('localhost') ? false : { rejectUnauthorized: false },
|
ssl: false,
|
||||||
max: 10,
|
max: 10,
|
||||||
idleTimeoutMillis: 30000,
|
idleTimeoutMillis: 30000,
|
||||||
connectionTimeoutMillis: 5000,
|
connectionTimeoutMillis: 5000,
|
||||||
@@ -38,15 +38,31 @@ if (dbUrl && (isProduction || process.env.FORCE_POSTGRES === 'true')) {
|
|||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('❌ PostgreSQL connection test failed:', error);
|
console.error('❌ PostgreSQL connection test failed:', error);
|
||||||
// Continue anyway, will use MemStorage as fallback
|
|
||||||
pool = null;
|
|
||||||
db = null;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Development fallback: use MemStorage
|
// Fallback: use Neon for development (but will be overridden by MemStorage)
|
||||||
console.log('🔧 DEV: Using MemStorage (development fallback)');
|
console.log('🔧 DEV: Using Neon (fallback, will use MemStorage)');
|
||||||
pool = null;
|
const { Pool, neonConfig } = await import('@neondatabase/serverless');
|
||||||
db = null;
|
const { drizzle } = await import('drizzle-orm/neon-serverless');
|
||||||
|
const ws = await import('ws');
|
||||||
|
|
||||||
|
neonConfig.webSocketConstructor = ws.default;
|
||||||
|
|
||||||
|
if (dbUrl) {
|
||||||
|
try {
|
||||||
|
pool = new Pool({ connectionString: dbUrl });
|
||||||
|
db = drizzle({ client: pool, schema });
|
||||||
|
} catch (error) {
|
||||||
|
console.error('❌ Neon connection failed, will use MemStorage:', error);
|
||||||
|
pool = null;
|
||||||
|
db = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Create dummy instances for development
|
||||||
|
pool = null;
|
||||||
|
db = null;
|
||||||
|
console.log('🔧 DEV: No DATABASE_URL, using MemStorage');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { db, pool };
|
export { db, pool };
|
||||||
Reference in new issue
Block a user