-
-
Notifications
You must be signed in to change notification settings - Fork 594
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
fix: user object may contain already deleted fields #1442
base: alpha
Are you sure you want to change the base?
Conversation
Thanks for opening this pull request!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the test! Do you think you could rewrite this in async/await? We are slowly getting rid of promise chains in tests.
@mtrezza Rewrote using async/await 👍 Happy to make any other adjustments. I also started trying to write a failing test in CoreManager.setRESTController({
request (method, path) {
expect(path).toBe('functions/myfunction')
return Promise.resolve(
{
result: {
objectId: 'abc123',
className: 'Item',
__type: 'Object',
createdAt: '2015-01-01T00:00:00.000Z',
updatedAt: '2015-01-01T00:00:00.000Z',
label: 'foobar',
},
},
200
);
},
ajax () {},
});
Cloud.run('myfunction').then(response => {
expect(response.get('label')).toBe('foobar')
}); |
@mtrezza I finished creating the failing test for the A couple notes:
Here are the failing tests: Parse.User.logIn case
Parse.Cloud.run case
|
Thanks! While writing the tests, did you also identify possible solutions for the fix? |
@mtrezza The most straightforward "solution" that comes to mind is simply disabling the Single Instance Controller. It seems to me that there may be a fundamental flaw in the Single Instance Controller's assumption that its But I don't know the context behind the creation and intended use case of the Single Instance Controller, and I don't know how significant the potential benefits are. If it has demonstrable value, then perhaps we can figure out a way to be smarter about clearing the state in the particular cases that we're dealing with here ( If I don't enable the Single Instance Controller in the
|
What could that be for example? |
@mtrezza In our case, we noticed that someone using our web app and mobile app at the same time could end up in a bad state. The web app was fetching the correct data from the server, but the web client was still using stale data that had been removed via the mobile app. But, in general, any direct interaction with the data in MongoDB will result in the Single Instance Controller's state being out of date. |
@mtrezza As an example of what I'm talking about, I just pushed a commit with all the unit tests passing where I call |
@mtrezza It looks like clearing the data as I mentioned causes a couple twitter/facebook flows to fail in the integration tests. If you or anyone else has any suggestions for ways to update the Single Instance controller to be more reliable, I'm happy to make more updates here. But in the short term on our end, we're probably going to disable the Single Instance controller. |
@mtrezza It turns out that disabling single instance mode has some pretty terrible side effects when it comes to how Parse updates the current user in local storage...so I think we're going to need to continue trying a solution here within the SDK. I can continue investigating when I have the time, but any assistance would be greatly appreciated. It would also be incredibly helpful if the impact of enabling or disabling single instance mode could be better documented. |
Maybe you could take a look at how single instance is used in code and what effects it has to suggest an amendment to the docs. |
Codecov Report
@@ Coverage Diff @@
## alpha #1442 +/- ##
=======================================
Coverage 99.94% 99.94%
=======================================
Files 61 61
Lines 5948 5950 +2
Branches 1354 1355 +1
=======================================
+ Hits 5945 5947 +2
Misses 3 3
Continue to review full report at Codecov.
|
New Pull Request Checklist
Issue Description
As discussed in #1347, the return from
Parse.User.logIn
can include fields that no longer exist on the user, even if the network response from parse-server does not include the removed fields. There is also an issue with the return fromParse.Cloud.run
.Related issue: #1347
Approach
This PR is a work in progress, initially containing only a failing test for the
Parse.User.logIn
case. If the failing test is confirmed to represent the issue well, a failing test forParse.Cloud.run
can also be added.No solution for the
Parse.User.logIn
case has yet been proposed.The proposed solution for the
Parse.Cloud.run
case is to update one of the cases indecode.js
to callParseObject.fromJSON(value, true)
instead ofParseObject.fromJSON(value)
.TODOs before merging
Parse.Cloud.run
caseParse.User.logIn
caseParse.Cloud.run
caseParse.User.logIn
case