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

Implemented a fix for the setTimeout unsubscribe thing #1567

Merged
merged 7 commits into from
Apr 19, 2017
Merged

Conversation

Poincare
Copy link
Contributor

@Poincare Poincare commented Apr 9, 2017

Should hopefully be a fix for the #1409 and some other related issues.

Took me a while to work out what kinds of tests broke and it's pretty likely that this change breaks behavior that we don't have tests for so we should release it with fingers crossed :)

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)
  • If this was a change that affects the external API, update the docs and post a link to the PR in the discussion

@Poincare Poincare requested review from calebmer and removed request for calebmer April 9, 2017 09:00
@Poincare Poincare changed the title [WIP] Implemented a fix for the setTimeout unsubscribe thing Implemented a fix for the setTimeout unsubscribe thing Apr 10, 2017
@Poincare Poincare requested a review from helfer April 10, 2017 15:02
@helfer
Copy link
Contributor

helfer commented Apr 12, 2017

@Poincare I'm a bit hesitant merging this, but we could release it under a next tag and ask as many people as we can to try it out. Before we do that though, I'd like to be sure that it leads to a significant performance improvement. Can you run some in-browser benchmarks or profiles and then report back?

@Poincare
Copy link
Contributor Author

Poincare commented Apr 16, 2017

@helfer

Safari:
dope

Chrome:
even more dope

🎉 🎉

@helfer
Copy link
Contributor

helfer commented Apr 16, 2017

Ok, remind me again, what was the baseline?


// Stop the query within the QueryManager if we can before
// this function returns.
const selectedObservers = that.observers.filter((obs: Observer<ApolloQueryResult<T>>) => obs !== observer);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this filter here really necessary, or could we just check if the length is 1?

Copy link
Contributor Author

@Poincare Poincare Apr 16, 2017

Choose a reason for hiding this comment

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

This filter is necessary due to some race condition that another part of the code mentions. I'm essentially matching the code in tearDownQuery.

@Poincare
Copy link
Contributor Author

Poincare commented Apr 16, 2017

Mean time for the baseline on Chrome, the browser we were having problems with, was 192.4 ms (see here).

next(result) {
resolve(result);

// Stop the query within the QueryManager if we can before
// this function returns.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should add more comments about why we need this.

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.

Thanks @Poincare, that's a pretty nice performance improvement!

I'm a bit worried that we don't have any documentation (in comments or otherwise) about how the result() function should be used, but looking at the code this shouldn't change the behavior of the function, so I think we can merge it.

@helfer helfer merged commit dadf4c9 into master Apr 19, 2017
@helfer helfer deleted the unsub_fix branch April 19, 2017 05:42
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 2, 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