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

Closing connections after calling return on AsyncIterator returned from watch #4700

Merged
merged 4 commits into from
Jul 4, 2022

Conversation

kraenhansen
Copy link
Member

@kraenhansen kraenhansen commented Jul 4, 2022

What, How & Why?

This closes an issue, where calling return on the AsyncIterator returned by watch wouldn't free up the network connection.

The existing code was assuming that return would be called on the underlying iterator of a generator function, which is not explicit in the specification. The fix is to get a reference to the response body iterator and explicitly call return on this, while deferring all other implementation to a renamed watchImpl method.

The syntax involved in unwrapping and rewrapping the iterator is a bit involved, since watch must return synchronously while the response body iterator is obtained through a promise.

☑️ ToDos

  • 📝 Changelog entry
  • 📝 Compatibility label is updated or copied from previous entry
  • 🚦 Tests (manually, locally)
  • 🔀 Executed flexible sync tests locally if modifying flexible sync
  • 📦 Updated internal package version in consuming package.jsons (if updating internal packages)
  • 📱 Check the React Native/other sample apps work if necessary
  • 📝 Public documentation PR created or is not necessary
  • 💥 Breaking label has been applied or is not necessary

@kraenhansen kraenhansen self-assigned this Jul 4, 2022
@cla-bot cla-bot bot added the cla: yes label Jul 4, 2022
Fixing test failure and adding a changelog
Copy link
Contributor

@fronck fronck left a comment

Choose a reason for hiding this comment

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

I that console.log was left in there by accident :)

packages/realm-web/src/index.ts Outdated Show resolved Hide resolved
Co-authored-by: FFranck <franck.franck@mongodb.com>
Copy link
Contributor

@fronck fronck left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Contributor

@kneth kneth left a comment

Choose a reason for hiding this comment

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

👍 😮

packages/realm-web/CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: Tom Duncalf <tom.duncalf@mongodb.com>
@kraenhansen kraenhansen merged commit 56a07df into master Jul 4, 2022
@kraenhansen kraenhansen deleted the td/kraens-generator-magic branch July 4, 2022 14:23
@kraenhansen kraenhansen changed the title Closing connections after calling return on AsyncIntegrator returned from watch Closing connections after calling return on AsyncIterator returned from watch Jul 4, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants