mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-29 09:01:06 +03:00
handles scenario where NodesPool require call fails
Currently, the following file results in an error: Flowise/packages/components/dist/nodes/documentloaders/Subtitles/Subtitles.js:3:15 The result is that initializeNodes fails on all nodes, and all other code in initDatabase fails to load
This commit is contained in:
@@ -4,6 +4,7 @@ import { Dirent } from 'fs'
|
|||||||
import { getNodeModulesPackagePath } from './utils'
|
import { getNodeModulesPackagePath } from './utils'
|
||||||
import { promises } from 'fs'
|
import { promises } from 'fs'
|
||||||
import { ICommonObject } from 'flowise-components'
|
import { ICommonObject } from 'flowise-components'
|
||||||
|
import logger from './utils/logger'
|
||||||
|
|
||||||
export class NodesPool {
|
export class NodesPool {
|
||||||
componentNodes: IComponentNodes = {}
|
componentNodes: IComponentNodes = {}
|
||||||
@@ -28,36 +29,40 @@ export class NodesPool {
|
|||||||
return Promise.all(
|
return Promise.all(
|
||||||
nodeFiles.map(async (file) => {
|
nodeFiles.map(async (file) => {
|
||||||
if (file.endsWith('.js')) {
|
if (file.endsWith('.js')) {
|
||||||
const nodeModule = await require(file)
|
try {
|
||||||
|
const nodeModule = await require(file)
|
||||||
|
|
||||||
if (nodeModule.nodeClass) {
|
if (nodeModule.nodeClass) {
|
||||||
const newNodeInstance = new nodeModule.nodeClass()
|
const newNodeInstance = new nodeModule.nodeClass()
|
||||||
newNodeInstance.filePath = file
|
newNodeInstance.filePath = file
|
||||||
|
|
||||||
// Replace file icon with absolute path
|
// Replace file icon with absolute path
|
||||||
if (
|
if (
|
||||||
newNodeInstance.icon &&
|
newNodeInstance.icon &&
|
||||||
(newNodeInstance.icon.endsWith('.svg') ||
|
(newNodeInstance.icon.endsWith('.svg') ||
|
||||||
newNodeInstance.icon.endsWith('.png') ||
|
newNodeInstance.icon.endsWith('.png') ||
|
||||||
newNodeInstance.icon.endsWith('.jpg'))
|
newNodeInstance.icon.endsWith('.jpg'))
|
||||||
) {
|
) {
|
||||||
const filePath = file.replace(/\\/g, '/').split('/')
|
const filePath = file.replace(/\\/g, '/').split('/')
|
||||||
filePath.pop()
|
filePath.pop()
|
||||||
const nodeIconAbsolutePath = `${filePath.join('/')}/${newNodeInstance.icon}`
|
const nodeIconAbsolutePath = `${filePath.join('/')}/${newNodeInstance.icon}`
|
||||||
newNodeInstance.icon = nodeIconAbsolutePath
|
newNodeInstance.icon = nodeIconAbsolutePath
|
||||||
|
|
||||||
// Store icon path for componentCredentials
|
// Store icon path for componentCredentials
|
||||||
if (newNodeInstance.credential) {
|
if (newNodeInstance.credential) {
|
||||||
for (const credName of newNodeInstance.credential.credentialNames) {
|
for (const credName of newNodeInstance.credential.credentialNames) {
|
||||||
this.credentialIconPath[credName] = nodeIconAbsolutePath
|
this.credentialIconPath[credName] = nodeIconAbsolutePath
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const skipCategories = ['Analytic']
|
const skipCategories = ['Analytic']
|
||||||
if (!skipCategories.includes(newNodeInstance.category)) {
|
if (!skipCategories.includes(newNodeInstance.category)) {
|
||||||
this.componentNodes[newNodeInstance.name] = newNodeInstance
|
this.componentNodes[newNodeInstance.name] = newNodeInstance
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
logger.error(`❌ [server]: Error during initDatabase with file ${file}:`, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ export class App {
|
|||||||
// Initialize database
|
// Initialize database
|
||||||
this.AppDataSource.initialize()
|
this.AppDataSource.initialize()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
logger.info('📦 [server]: Data Source has been initialized!')
|
logger.info('📦 [server]: Data Source is being initialized!')
|
||||||
|
|
||||||
// Run Migrations Scripts
|
// Run Migrations Scripts
|
||||||
await this.AppDataSource.runMigrations({ transaction: 'each' })
|
await this.AppDataSource.runMigrations({ transaction: 'each' })
|
||||||
@@ -112,6 +112,7 @@ export class App {
|
|||||||
|
|
||||||
// Initialize telemetry
|
// Initialize telemetry
|
||||||
this.telemetry = new Telemetry()
|
this.telemetry = new Telemetry()
|
||||||
|
logger.info('📦 [server]: Data Source has been initialized!')
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
logger.error('❌ [server]: Error during Data Source initialization:', err)
|
logger.error('❌ [server]: Error during Data Source initialization:', err)
|
||||||
|
|||||||
Reference in New Issue
Block a user