parse-community / parse-community/parse-server
Redis liveQueryPublisher connection not closed on shutdown
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 21.4k
- Forks
- 4.8k
- Avg merge
- 7h 45m
- Merged PRs (30d)
- 11
Description
New Issue Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
- I can reproduce the issue with the latest version of Parse Server.
Issue Description
Hello! 👋 I am having a need to handle graceful shutdown in an application, and I found the handleShutdown method inside the ParseServer class.
Using this method works great when only using MongoDB (and even a cache/file adapters) but breaks down whenever I set up a redisURL inside the liveQuery configuration, which is necessary for our use case (we need it to handle Parse inside a k8s cluster).
Digging deeper, I found that the liveQueryController creates a publisher with a RedisPubSub instance when instantiating ParseServer, but it's never disconnected from during shutdown (because its corresponding controller is not referenced inside the ParseServer class).
Steps to reproduce
Run the following code, having MongoDB and Redis instances started and listening in their default ports beforehand. The following code provides a minimal reproduction of the issue (I can provide a minimal repo reproducing the issue if necessary)
const { ParseServer } = require('parse-server');
const parseServer = ParseServer.start({
appId: 'someAppId',
masterKey: 'someMasterKey',
databaseURI: 'mongodb://127.0.0.1:27017',
liveQuery: {
redisURL: 'redis://127.0.0.1:6379',
},
serverStartComplete: async () => {
parseServer.server.close(); // Closes http server
await parseServer.handleShutdown(); // Successfully disconnects from DB, but not from Redis
console.log('Node process is left hanging indefinitely, connected to Redis');
},
});
Actual Outcome
The process is left hanging indefinitely, instead of correctly handling shutdown; even when a SIGINT is sent.
Expected Outcome
The process is expected to exit (with status 0), in the same way it exits when only using the database configuration. The following code (without the liveQuery configuration) works just as expected:
const { ParseServer } = require('parse-server');
const parseServer = ParseServer.start({
appId: 'someAppId',
masterKey: 'someMasterKey',
databaseURI: 'mongodb://127.0.0.1:27017',
serverStartComplete: async () => {
parseServer.server.close();
await parseServer.handleShutdown();
console.log('Node process exits after this callback!');
},
});
Failing Test Case / Pull Request
- 🤩 I submitted a PR with a fix and a test case.
- 🧐 I submitted a PR with a failing test case.
Environment
Server
- Parse Server version:
4.5.0 - Operating system:
Mac OS(also tested onUbuntu 18.04 LTS) - Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): N/A
Database
- System (MongoDB or Postgres):
MongoDB - Database version:
4.4.5 - Redis version:
6.2.2 - Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): N/A
Client
- SDK (iOS, Android, JavaScript, PHP, Unity, etc): N/A
- SDK version: N/A
Logs
No relevant logs to show.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue points to ParseServer.handleShutdown, liveQueryController, and RedisPubSub; start there and inspect the failing test case submitted with the issue. Confirm the shutdown path disconnects the liveQuery Redis publisher and that the reproduction exits cleanly with status 0. Done means the Redis connection no longer keeps the Node process alive.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, mongodb, node.js, redis
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100