Skip to content

Document global var / setting idle_timeout solutions for long-running development processes eg. Next.js #119

Description

@karlhorky

Hi @porsager! 👋

Since a while now, students at @upleveled have been running into an issue where refreshes of a page (and Fast Refresh) are causing further database connections, and the old connections are not going away. This leads to confusing errors like (also mentioned in #42):

Error: remaining connection slots are reserved for non-replication superuser connections

The teardown / cleanup section in the readme with the prexit example appears to be helpful, but process.exit is not actually called during the development workflow (multiple page refreshes and Fast Refresh hot reloads when a file is changed).

As far as I can tell, there are a couple of different solutions to this:

  1. Set a global variable that will persist across page reloads and Fast Refresh (like this: Dev mode hot reload loses database connection vercel/next.js#7811 (comment))
  2. Set an idle_timeout that will cause the idle connections to be terminated fairly quickly (eg. after 2 seconds)

Would you be open to me creating a section in the readme addressing this problem with option 1 as a recommended solution for development workflows for these long-running apps? With maybe option 2 as an "alternative" solution?

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions