Skip to content

Commit 2290ba9

Browse files
authored
Merge pull request #1786 from Jaredude/bug/nodespool-file-map-error-handling
handles scenario where NodesPool require call fails
2 parents 6247b67 + 23f7e78 commit 2290ba9

File tree

2 files changed

+30
-24
lines changed

2 files changed

+30
-24
lines changed

packages/server/src/NodesPool.ts

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Dirent } from 'fs'
44
import { getNodeModulesPackagePath } from './utils'
55
import { promises } from 'fs'
66
import { ICommonObject } from 'flowise-components'
7+
import logger from './utils/logger'
78

89
export class NodesPool {
910
componentNodes: IComponentNodes = {}
@@ -28,36 +29,40 @@ export class NodesPool {
2829
return Promise.all(
2930
nodeFiles.map(async (file) => {
3031
if (file.endsWith('.js')) {
31-
const nodeModule = await require(file)
32+
try {
33+
const nodeModule = await require(file)
3234

33-
if (nodeModule.nodeClass) {
34-
const newNodeInstance = new nodeModule.nodeClass()
35-
newNodeInstance.filePath = file
35+
if (nodeModule.nodeClass) {
36+
const newNodeInstance = new nodeModule.nodeClass()
37+
newNodeInstance.filePath = file
3638

37-
// Replace file icon with absolute path
38-
if (
39-
newNodeInstance.icon &&
40-
(newNodeInstance.icon.endsWith('.svg') ||
41-
newNodeInstance.icon.endsWith('.png') ||
42-
newNodeInstance.icon.endsWith('.jpg'))
43-
) {
44-
const filePath = file.replace(/\\/g, '/').split('/')
45-
filePath.pop()
46-
const nodeIconAbsolutePath = `${filePath.join('/')}/${newNodeInstance.icon}`
47-
newNodeInstance.icon = nodeIconAbsolutePath
39+
// Replace file icon with absolute path
40+
if (
41+
newNodeInstance.icon &&
42+
(newNodeInstance.icon.endsWith('.svg') ||
43+
newNodeInstance.icon.endsWith('.png') ||
44+
newNodeInstance.icon.endsWith('.jpg'))
45+
) {
46+
const filePath = file.replace(/\\/g, '/').split('/')
47+
filePath.pop()
48+
const nodeIconAbsolutePath = `${filePath.join('/')}/${newNodeInstance.icon}`
49+
newNodeInstance.icon = nodeIconAbsolutePath
4850

49-
// Store icon path for componentCredentials
50-
if (newNodeInstance.credential) {
51-
for (const credName of newNodeInstance.credential.credentialNames) {
52-
this.credentialIconPath[credName] = nodeIconAbsolutePath
51+
// Store icon path for componentCredentials
52+
if (newNodeInstance.credential) {
53+
for (const credName of newNodeInstance.credential.credentialNames) {
54+
this.credentialIconPath[credName] = nodeIconAbsolutePath
55+
}
5356
}
5457
}
55-
}
5658

57-
const skipCategories = ['Analytic']
58-
if (!skipCategories.includes(newNodeInstance.category)) {
59-
this.componentNodes[newNodeInstance.name] = newNodeInstance
59+
const skipCategories = ['Analytic']
60+
if (!skipCategories.includes(newNodeInstance.category)) {
61+
this.componentNodes[newNodeInstance.name] = newNodeInstance
62+
}
6063
}
64+
} catch (err) {
65+
logger.error(`❌ [server]: Error during initDatabase with file ${file}:`, err)
6166
}
6267
}
6368
})

packages/server/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export class App {
8585
// Initialize database
8686
this.AppDataSource.initialize()
8787
.then(async () => {
88-
logger.info('📦 [server]: Data Source has been initialized!')
88+
logger.info('📦 [server]: Data Source is being initialized!')
8989

9090
// Run Migrations Scripts
9191
await this.AppDataSource.runMigrations({ transaction: 'each' })
@@ -112,6 +112,7 @@ export class App {
112112

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

0 commit comments

Comments
 (0)