Skip to content

Unhandled rejection TypeError: Cannot read property 'query' of undefined #9218

Closed

Description

@gabegorelick

What are you doing?

Still trying to reproduce, but I periodically see this error during Resource Timeout events:

Unhandled rejection TypeError: Cannot read property 'query' of undefined
    at parameters.length.Promise (/sequelize/lib/dialects/postgres/query.js:65:54)
    at Promise._execute (/sequelize/node_modules/bluebird/js/release/debuggability.js:300:9)
    at Promise._resolveFromExecutor (/sequelize/node_modules/bluebird/js/release/promise.js:483:18)
    at new Promise (/sequelize/node_modules/bluebird/js/release/promise.js:79:10)
    at Query.run (/sequelize/lib/dialects/postgres/query.js:65:9)
    at Promise.try.then.connection (/sequelize/lib/sequelize.js:558:20)
    at tryCatcher (/sequelize/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/sequelize/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/sequelize/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromiseCtx (/sequelize/node_modules/bluebird/js/release/promise.js:606:10)
    at Async._drainQueue (/sequelize/node_modules/bluebird/js/release/async.js:138:12)
    at Async._drainQueues (/sequelize/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues (/sequelize/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:789:20)
    at tryOnImmediate (timers.js:751:5)
    at processImmediate [as _immediateCallback] (timers.js:722:5)

This is similar to #8087, but since a fix for that has been merged the error must come from a different source.

What do you expect to happen?

No error

What is actually happening?

Error

Dialect: postgres
Dialect version: 9.6
Database version: 9.6
Sequelize version: 4.37.4
Tested with latest release: Yes

Activity

  1. gabegorelick commented on Mar 22, 2018

    @gabegorelick
    ContributorAuthor

    Tracked the issue down to this:

    sequelize/lib/sequelize.js

    Lines 552 to 554 in 20cac7a

    return options.transaction
    ? options.transaction.connection
    : this.connectionManager.getConnection(options);

    options.transaction.connection is undefined at this point, but transaction is not yet finished. After we return from this promise, finished is rollback. Could be a race condition?

    Seems very similar to #8087, but I've confirmed I have the fix from #9051.

  2. added
    type: bug
    on Mar 23, 2018
  3. sushantdhiman commented on Mar 23, 2018

    @sushantdhiman
    Contributor

    Last I tried my testcase was still throwing that error with current fix, may be that test case represent your case as well

  4. itsmepetrov commented on Apr 25, 2018

    @itsmepetrov

    Any updates?

  5. mattmackay76 commented on May 15, 2018

    @mattmackay76

    I'm getting this issue on Sequelize version: 4.37.7
    Anybody have any ideas on this?

  6. picq commented on Jun 4, 2018

    @picq

    This issue still exists, does anybody have a clue how fix it ?

  7. omguhh commented on Jul 19, 2018

    @omguhh

    Any update on this?

  8. bjitfreelancing commented on Jul 28, 2018

    @bjitfreelancing

    Even I am facing same issue with "pg": "^7.4.3", "sequelize": "^4.37.7"

  9. holm commented on Aug 6, 2018

    @holm
    Contributor

    We just saw this in production also. I tried adding @sushantdhiman testcase from #8087 (comment), but does correctly throw a TimeoutError and there is no unhandled rejection.

  10. hackhat commented on Sep 1, 2018

    @hackhat

    Still happening, any news?

  11. sushantdhiman commented on Sep 7, 2018

    @sushantdhiman
    Contributor

    Resolved by #9879

    Now you should see ConnectionAcquireTimeoutError when transaction is unable to acquire connection along with proper error Transaction cannot be rolled back because it never started when such transaction try to rollback

    Edit: Released as 5.0.0-beta.12

  12. soryy708 commented on Feb 10, 2019

    @soryy708
    Contributor

    Somehow I got the same error by misusing transactions.
    Here's code to reproduce:

    sequelize.transaction(async (transaction) => {
        models.File.create(fileInfo, {transaction: {transaction}});
    }
    

    Note that the transaction is inside an unnecessary object.
    Probably should not be fixed by sequelize, but may be useful for people doing debugging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions