Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The connection reserved for LISTEN is not closed after the last subscribed-to channel is unsubscribed from #1022

Open
acarstoiu opened this issue Jan 28, 2025 · 0 comments

Comments

@acarstoiu
Copy link
Contributor

I noticed that the Node.js process does not come to an end after using the listening mechanism. That's because the connection reserved for LISTEN statements is not closed even after the last channel is unsubscribed from. And even if all other connections are closed via close().

Use this program:

const sql = require("postgres")(...);

sql.listen("topic", console.log.bind(null, "Received:"), async () => {
	await sql.unsafe(`SELECT pg_notify('topic', 'something')`);
}).then(({ unlisten }) => {
	setTimeout(async () => {
		await sql.close();
		await unlisten();
		// sql.unsafe(`SELECT 1`);
	}, 1000);
});
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

No branches or pull requests

1 participant