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

Fix #647 - Avoid store reading errors on mutations after a failed/canceled query #651

Closed
wants to merge 4 commits into from

Conversation

rricard
Copy link
Contributor

@rricard rricard commented Sep 15, 2016

Fixes #647

TODO:

  • If this PR is a new feature, reference an issue where a consensus about the design was reached (not necessary for small changes)
  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass
  • Update CHANGELOG.md with your change
  • Add your name and email to the AUTHORS file (optional)
  • Refactor

Post-mutation failing store reading during updateQueries.

@rricard
Copy link
Contributor Author

rricard commented Sep 16, 2016

I don't see how to pass AppVeyor here, something seems broken even before this PR, am I right ?

rricard added a commit that referenced this pull request Sep 16, 2016
@rricard
Copy link
Contributor Author

rricard commented Sep 16, 2016

rebased, appveyor passes = yay!

@rricard
Copy link
Contributor Author

rricard commented Sep 19, 2016

rebased! @stubailo are you could considering merging that soon? this bug hurts us a lot lately, I can make changes if you need me to do them. Thanks!

Copy link
Contributor

@helfer helfer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rricard this seems more like a workaround than an actual fix, so I'm a bit reluctant to merging it. I'm not sure about it, but to me it seems like it would be more appropriate to check the query state and then return null or skip the updateQueries all together if the query was cancelled or is still in flight and partialData is false. Although in that case we'd have to attempt to queue up the updates and apply them later, I guess.

In the end, this all comes down to how we want to do offline support. Offline support is very important, but it's also not trivial to implement because of all the weird states you can get into.

@helfer
Copy link
Contributor

helfer commented Sep 19, 2016

@rricard can you work off of your own fork for now? I'd rather wait until we have a real fix than patch things up half way.

@helfer
Copy link
Contributor

helfer commented Sep 19, 2016

See also #487, which seems to be the same error.

@helfer
Copy link
Contributor

helfer commented Sep 19, 2016

Since this is a pretty serious bug imo, we'll make sure it gets fixed soon!

@helfer
Copy link
Contributor

helfer commented Sep 19, 2016

Also, how does this relate to #511, which you also filed? That sounds pretty similar to me as well.

@rricard
Copy link
Contributor Author

rricard commented Sep 19, 2016

@helfer whoops! forgot about this one! Closing it!

@rricard
Copy link
Contributor Author

rricard commented Sep 19, 2016

@helfer in general, working on a fork of the client is a huge pain, we did it once and we're not doing it again, I think (because you also need to fork react-apollo and last time we had to do that, we couldn't just get it out of git like this, we had to recompile + republish under a new name on npm...).

I really really prefer working on my own personal time on this to help you refactor all of this because the bug itself is really hard on us (cancellation is the biggest issue I think, fails after errored queries just made us make the schema more stable, which was a good thing).

@rricard
Copy link
Contributor Author

rricard commented Sep 19, 2016

In general, I agree, that's not the kind of fix I like too, for me the idea was more about providing a test and an early fix. Then we refactor that ASAP but with less pressure since the bug is not there, the test maintaining it down. I think, as discussed in #615, that by simplifying the query diffing we can get it right.

@rricard
Copy link
Contributor Author

rricard commented Sep 19, 2016

Also the solution you are proposing seems good, I didn't thought about offline support and I have to say that's a complex problem. I'll see tomorrow if I can get a better fix without refactoring the whole thing!

} catch (e) {
if (!/can't find field/i.test(e.message)) {
throw e;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@helfer I agree, this feels completely hacky now that I'm coming back here

@rricard rricard added in progress and removed ready labels Sep 19, 2016
rricard added a commit that referenced this pull request Sep 20, 2016
@rricard
Copy link
Contributor Author

rricard commented Sep 20, 2016

@helfer or anyone affected:

I'm getting the patched version like this in the meantime, not perfect, but will do the trick:

package.json

{
  "scripts": {
    "postinstall": "cd ./node_modules/apollo-client; npm i; npm run prepublish"
  },
  "dependencies": {
    "apollo-client": "apollostack/apollo-client#fix-647"
  }
}

Note that doing this will slow down pretty much everything... (CI, deploy, etc...)

@rricard
Copy link
Contributor Author

rricard commented Sep 20, 2016

And... no it doesn't work, tsconfig gets npmignored

@rricard
Copy link
Contributor Author

rricard commented Sep 20, 2016

Removing the NPM ignore for now so I can use it as a fork!

@helfer
Copy link
Contributor

helfer commented Sep 20, 2016

@rricard ok, I'll try to fix this soon. It might take until next week though, because we'll be away from tomorrow until Monday.

Post-mutation failing store reading during updateQueries.
We avoid running the reducer on those cases

Fixes #647
This allows using this branch as an npm fork!

TODO: revert this commit
@rricard
Copy link
Contributor Author

rricard commented Sep 21, 2016

@helfer don't worry, either I'll find some time to propose a better fix, either I'll wait, take your time away, enjoy it and don't think about this bug! 👍

@rricard
Copy link
Contributor Author

rricard commented Sep 22, 2016

Closing this one: followup in #696

@rricard rricard closed this Sep 22, 2016
@zol zol removed the in progress label Sep 22, 2016
@jbaxleyiii jbaxleyiii deleted the fix-647 branch July 20, 2017 17:39
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants