Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix initDatabase function by proper use of await in try catch #2360

Merged
merged 2 commits into from
May 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 25 additions & 26 deletions packages/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,40 +43,39 @@

async initDatabase() {
// Initialize database
this.AppDataSource.initialize()
.then(async () => {
logger.info('📦 [server]: Data Source is initializing...')
try {
await this.AppDataSource.initialize();

Check failure on line 47 in packages/server/src/index.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

Delete `;`
logger.info('📦 [server]: Data Source is initializing...')

// Run Migrations Scripts
await this.AppDataSource.runMigrations({ transaction: 'each' })
// Run Migrations Scripts
await this.AppDataSource.runMigrations({ transaction: 'each' })

// Initialize nodes pool
this.nodesPool = new NodesPool()
await this.nodesPool.initialize()
// Initialize nodes pool
this.nodesPool = new NodesPool()
await this.nodesPool.initialize()

// Initialize chatflow pool
this.chatflowPool = new ChatflowPool()
// Initialize chatflow pool
this.chatflowPool = new ChatflowPool()

// Initialize API keys
await getAPIKeys()
// Initialize API keys
await getAPIKeys()

// Initialize encryption key
await getEncryptionKey()
// Initialize encryption key
await getEncryptionKey()

// Initialize Rate Limit
const AllChatFlow: IChatFlow[] = await getAllChatFlow()
await initializeRateLimiter(AllChatFlow)
// Initialize Rate Limit
const AllChatFlow: IChatFlow[] = await getAllChatFlow()
await initializeRateLimiter(AllChatFlow)

// Initialize cache pool
this.cachePool = new CachePool()
// Initialize cache pool
this.cachePool = new CachePool()

// Initialize telemetry
this.telemetry = new Telemetry()
logger.info('📦 [server]: Data Source has been initialized!')
})
.catch((err) => {
logger.error('❌ [server]: Error during Data Source initialization:', err)
})
// Initialize telemetry
this.telemetry = new Telemetry()
logger.info('📦 [server]: Data Source has been initialized!')
} catch (error) {
logger.error('❌ [server]: Error during Data Source initialization:', error);

Check failure on line 77 in packages/server/src/index.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

Delete `;`
}
}

async config(socketIO?: Server) {
Expand Down
Loading