user3221132
user3221132

Reputation:

Console.log not being run when using promise in NodeJS

This is driving me crazy. I have the code below and when I run it, I only have debug-1 print. If I comment out the where declaration I get debug-1 and debug-2 to print.

        console.log( 'debug-1' )
        var where = {
            compound_id: study.compound_id,
            species: {
                "like": ( species + "*" )
            },
            study_start: {
                "<=": study.study_start
            },
            study_start: {
                ">=": threeYearsBeforeStudy
            }
        }
        console.log( 'debug-2' )

Super peculiar. I have this block inside a promise, but I'm sure that shouldn't be an issue.

Upvotes: 3

Views: 3303

Answers (1)

Anthony
Anthony

Reputation: 14269

Add the code

process.on('unhandledRejection', console.log.bind(console))

to the top of your node file after your dependencies. That will let you know what is going wrong, it seems you are running into an error with your promise without handling it anywhere.

Upvotes: 9

Related Questions