Skip to content

Unhandled rejection TypeError: connectionLock.unwrap is not a function #8833

Closed

Description

@shilu911

What are you doing?

Just connect to the server and do normal CRUD operations.

{
    "username": "SA",
    "password": "Sl19840911*",
    "database": "aliya",
    "host": "192.168.0.66",
    "dialect": "mssql",
    "pool": {
      "max": 20,
      "min": 5,
      "idle": 20000,
      "acquire": 20000
    }
  }

What do you expect to happen?

Just want the application can work continually

What is actually happening?

I check the application status everyday, and find this error everyday. The only way to make it work again is to restart the application.

Unhandled rejection TypeError: connectionLock.unwrap is not a function
at ConnectionManager.validate (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/sequelize/lib/dialects/mssql/connection-manager.js:149:39)
at ConnectionManager._validate (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:347:43)
at Pool._testOnBorrow (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/generic-pool/lib/Pool.js:163:45)
at Pool._dispense (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/generic-pool/lib/Pool.js:239:14)
at Pool.acquire (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/generic-pool/lib/Pool.js:449:10)
at promise.then (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:274:24)
From previous event:
at ConnectionManager.getConnection (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:273:20)
at Promise.try (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/sequelize/lib/sequelize.js:538:92)
From previous event:
at Sequelize.query (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/sequelize/lib/sequelize.js:445:23)
at QueryInterface.select (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/sequelize/lib/query-interface.js:1040:27)
at Promise.try.then.then.then (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/sequelize/lib/model.js:1565:34)
at runCallback (timers.js:781:20)
at tryOnImmediate (timers.js:743:5)
at processImmediate [as _immediateCallback] (timers.js:714:5)
From previous event:
at Function.findAll (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/sequelize/lib/model.js:1562:8)
at Function.findAndCount (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/sequelize/lib/model.js:1870:28)
at Object._callee$ (/Users/lushi/Documents/Aliya's Food/platform-backend/services/role_service.js:4:24)
at tryCatch (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:117:21)
at step (/Users/lushi/Documents/Aliya's Food/platform-backend/services/role_service.js:51:191)
at /Users/lushi/Documents/Aliya's Food/platform-backend/services/role_service.js:51:437
at Promise ()
at Object. (/Users/lushi/Documents/Aliya's Food/platform-backend/services/role_service.js:51:99)
at Object.getAll (/Users/lushi/Documents/Aliya's Food/platform-backend/services/role_service.js:24:21)
at _callee$ (/Users/lushi/Documents/Aliya's Food/platform-backend/routes/role.js:10:41)
at tryCatch (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:117:21)
at step (/Users/lushi/Documents/Aliya's Food/platform-backend/routes/role.js:20:191)
at /Users/lushi/Documents/Aliya's Food/platform-backend/routes/role.js:20:437
at Promise ()
at /Users/lushi/Documents/Aliya's Food/platform-backend/routes/role.js:20:99
at /Users/lushi/Documents/Aliya's Food/platform-backend/routes/role.js:8:1
at Layer.handle [as handle_request] (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/express/lib/router/layer.js:95:5)
at /Users/lushi/Documents/Aliya's Food/platform-backend/node_modules/express/lib/router/index.js:281:22

Dialect: mssql
tedious version: 2.1.1
Database version: SQL Server 2017 (RC1) - 14.0.800.90 (X64)
Sequelize version: 4.28.6
Tested with latest release: Yes, 4.28.6

Note : Your issue may be ignored OR closed by maintainers if it's not tested against latest version OR does not follow issue template.

Activity

  1. added
    type: bug
    dialect: mssql
    good first issue
    on Jan 11, 2018
  2. sushantdhiman commented on Jan 11, 2018

    @sushantdhiman
    Contributor

    We can check if object that is being validated by pool is indeed a connectionLock

    const connection = connectionLock.unwrap();

  3. shilu911 commented on Jan 11, 2018

    @shilu911
    Author

    Hi @sushantdhiman , I was wondering if there is a workaround for now? I want to keep my app working instead of restarting it everyday. Thank you !

  4. sushantdhiman commented on Jan 12, 2018

    @sushantdhiman
    Contributor

    You can override validate function yourself with config pool.validate where you can check connection.unwrap exists before calling it.

  5. cedricVu commented on Jan 15, 2018

    @cedricVu

    Hi @sushantdhiman , I'm having the same problem. I did not get your idea. Could you please make it more clearly? Thanks

  6. sushantdhiman commented on Jan 15, 2018

    @sushantdhiman
    Contributor

    @VictorVuSon you need to add a config pool.validate like this

    {
        "dialect": "mssql",
        "pool": {
            "validate": function (connectionLock) {
                 if (!connectionLock.unwrap) return false;
    
                 const connection = connectionLock.unwrap();
                 return connection && connection.loggedIn;
            }
        }
      }
  7. cedricVu commented on Jan 15, 2018

    @cedricVu

    Big thanks to you @sushantdhiman

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

    dialect: mssqlgood first issuetype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions