#9242·sequelize

Cannot read property 'destroy' of undefined

Author: PonjimonCreated Mar 26, 2018Updated Sep 29, 2026

What are you doing?

Just regular selects (findAll, findById, etc..). It doesn't really matter in this case. For some reason, I get the above error exactly at this line: https://github.com/sequelize/sequelize/blob/master/lib/dialects/abstract/connection-manager.js#L166

As I see, there is no check whatsoever if this key in this.pool actually exists and apparently, there is a case where it gets removed or not created in the first place. The problem is: I don't know how to reproduce this or why it happens, it happens very rarely, but it happens.

What do you expect to happen?

That the connection in the pool is still there when it tries to destroy it.

What is actually happening?

The connection seems to be removed from the pools array before the destroy call, so the call fails.

Dialect: mysql Dialect version: Database version: AWS Aurora MySQL 5.7 Sequelize version: ^4.33.2 Tested with latest release: 4.37.4