You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to fix a sporadic Sequelize connection error bug, we made a quick fix that re-initializes a Sequelize instance with each lambda invocation.
However, we found this new Sequelize documentation PR (still under review) that had recommendations on lambda best practices. A great recommendation is to:
create a global sequelize variable (during the lambda Init phase, i.e. outside the handler)
during the lambda Invoke phase (within the handler), restart connection pool using sequelize.connectionManager.initPools() and close the connections at the end of the phase using sequelize.connectionManager.close()
In order to fix a sporadic Sequelize connection error bug, we made a quick fix that re-initializes a Sequelize instance with each lambda invocation.
However, we found this new Sequelize documentation PR (still under review) that had recommendations on lambda best practices. A great recommendation is to:
Init
phase, i.e. outside the handler)Invoke
phase (within the handler), restart connection pool usingsequelize.connectionManager.initPools()
and close the connections at the end of the phase usingsequelize.connectionManager.close()
Refer to https://github.com/sequelize/sequelize/blob/114c10eb09353cd32a630e42454a5d587ab0aed3/docs/manual/other-topics/aws-lambda.md
The text was updated successfully, but these errors were encountered: