parse-community / parse-community/parse-server
`User` changes take significant time to propagate between threads
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
- [X ] I am not disclosing a vulnerability.
- [X ] I am not just asking a question.
- [X ] I have searched through existing issues.
- [X ] I can reproduce the issue with the latest version of Parse Server.
Issue Description
Making a change to a User in one thread, does not show up immediately in another worker thread. For instance, if you create a super simple cloud function (see below) that changes a property on the User object and another cloud function that reads back that value (after having it hydrated from the request)... even if you await the change function, if you call the readUser function immediately after you will get the original value back.
If you add an async wait and THEN call the readUser function, the value will be updated properly. Even running locally the wait must be several seconds to be effective.
Steps to reproduce
- Spawn 2 or more instances of your server using Throng or similar Node clustering module
- Call updateUser function from client w/
await - Call fetchUser function from client
- Notice that the updated value is NOT correct
Actual Outcome
- Original value of
User.testVal
Expected Outcome
- Updated value of
User.testVal
Failing Test Case / Pull Request
Will look at this... not sure if test env has ability to utilize clustering.
- 🤩 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: macOS 10.15.7
- Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): local
Database
- System (MongoDB or Postgres): MongoDB
- Database version: 4.4.4
- Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): MongoDB Atlas
Client
- SDK (iOS, Android, JavaScript, PHP, Unity, etc): JavaScript
- SDK version: 2.19.0
Functions
Parse.Cloud.define('updateUser', async (req: Parse.Cloud.FunctionRequest) => {
const user = req.user
if (!user) {
throw 'no user'
}
const token = user.getSessionToken()
const updatedThing = await user.save({ testVal: String(new Date().getTime()) }, { sessionToken: token })
console.log('updatedThing:', JSON.stringify(updatedThing.toJSON(), null, 4))
console.log('pid:', JSON.stringify(process.pid, null, 4))
console.log('testVal (after updating):', user.get('testVal'))
})
Parse.Cloud.define('fetchUser', async (req: Parse.Cloud.FunctionRequest) => {
const user = req.user
if (!user) {
throw 'no user'
}
console.log('pid:', JSON.stringify(process.pid, null, 4))
console.log('testVal:', user.get('testVal'))
})
Client Test function
async clickTestThign () {
await this.fetchUserTest()
await this.updateUserTest()
this.fetchUserTest()
this.fetchUserTest()
this.fetchUserTest()
this.fetchUserTest()
this.fetchUserTest()
await new Promise<void>(res => setTimeout(async () => {
this.fetchUserTest()
this.fetchUserTest()
this.fetchUserTest()
this.fetchUserTest()
res()
}, 2000))
}
Logs
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
Start by reproducing the issue with the updateUser and fetchUser cloud functions across two or more server instances, using the clustering setup described. Compare the request-hydrated User values and process IDs, then add a regression test if the test environment supports clustering; done means an immediately following fetch observes the updated testVal.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, mongodb, node.js
- Domain
- backend, databases, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100