@@ -4,6 +4,7 @@ import { Dirent } from 'fs'
44import { getNodeModulesPackagePath } from './utils'
55import { promises } from 'fs'
66import { ICommonObject } from 'flowise-components'
7+ import logger from './utils/logger'
78
89export 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 } )
0 commit comments