Skip to content

Updated the disconnect() method to wait until the connection has been… - #9911

Merged
sushantdhiman merged 2 commits into
sequelize:masterfrom
AlastairTaft:fix-for-improperly-closing-connections
Sep 13, 2018
Merged

sushantdhiman merged 2 commits into
sequelize:masterfrom
AlastairTaft:fix-for-improperly-closing-connections

Conversation

@AlastairTaft

@AlastairTaft AlastairTaft commented Sep 12, 2018 •

Copy link
Copy Markdown
Contributor

… ended.

Pull Request check-list

Please make sure to review and check all of these items:

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)? No, but the same two tests aren't passing that are on master.
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description of change

We're using sequelize on AWS lambda with the postgres dialect and the script execution is halted before the connection is closed which causes weird issues with database connections. This change ensures that the connection is properly closed before the execution ends.

Helps with #8468.

connection.end();
resolve();
connection.end()
.then(() => resolve());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return Promise.fromCallback(callback => connection.end(callback));

@sushantdhiman

Copy link
Copy Markdown
Contributor

I don't think this will solve issue you are facing. I really want pool to shutdown when event loop is empty but node-pool implementation is such it keep process alive thus preventing clean shutdown.

@AlastairTaft

AlastairTaft commented Sep 13, 2018 •

Copy link
Copy Markdown
Contributor Author

Do you know if fixing that is on node-pool/generic-pool's roadmap?
EDIT: Based on your comment on the other thread I think you're thinking of either switching to generic-pool v2 or rolling a different pooling library.

@sushantdhiman
sushantdhiman merged commit 56d5fee into sequelize:master Sep 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants