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(ws): Subscriptions async iterator completes and better error handling #1841

Merged
merged 8 commits into from
Apr 21, 2021
Merged

fix(ws): Subscriptions async iterator completes and better error handling #1841

merged 8 commits into from
Apr 21, 2021

Conversation

enisdenjo
Copy link
Member

Closes #1827

@changeset-bot
Copy link

changeset-bot bot commented Apr 19, 2021

🦋 Changeset detected

Latest commit: 933444a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@graphiql/toolkit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

},
});
return {
[Symbol.asyncIterator]() {
Copy link
Collaborator

@n1ru4l n1ru4l Apr 19, 2021

Choose a reason for hiding this comment

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

Note that Symbol.asyncIterator is not available in Safari 14 (iOS), that is why I create push-pull-async-iterable-iterator in the first place.

Copy link
Member Author

Choose a reason for hiding this comment

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

Only reason why I replaced it is #1827 (comment).

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, shouldn't the transpilation be handled by the user? If you'd like to support Safari 14 on iOS, simply polyfill the async iterator with Babel on build step. @acao what is your take on this?

Copy link
Collaborator

@n1ru4l n1ru4l Apr 19, 2021

Choose a reason for hiding this comment

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

I have no strong feelings about this. For myself, I can say that I am shipping an app with Safari 14 support and try to avoid babel transforms where possible, that is why I created the lib, later I had the need to transform sinks into AsyncIterables as they are easier to map/filter etc so I added it to the library. If GraphiQL does not need to rely on push-pull-async-iterable-iterator I am totally fine with it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted back to using the push-pull-async-iterable-iterator following v2.1.3.

@codecov
Copy link

codecov bot commented Apr 19, 2021

Codecov Report

Merging #1841 (933444a) into main (2d91916) will increase coverage by 0.10%.
The diff coverage is 46.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1841      +/-   ##
==========================================
+ Coverage   65.70%   65.81%   +0.10%     
==========================================
  Files          85       85              
  Lines        5106     5116      +10     
  Branches     1631     1625       -6     
==========================================
+ Hits         3355     3367      +12     
+ Misses       1747     1745       -2     
  Partials        4        4              
Impacted Files Coverage Δ
...ackages/graphiql-toolkit/src/create-fetcher/lib.ts 50.90% <11.11%> (-8.67%) ⬇️
packages/graphiql/src/components/GraphiQL.tsx 58.09% <100.00%> (+0.58%) ⬆️
...hql-language-service-server/src/findGraphQLTags.ts 64.89% <100.00%> (+4.25%) ⬆️
packages/graphiql/src/components/ToolbarButton.tsx 92.85% <0.00%> (+21.42%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65aa648...933444a. Read the comment docs.

@enisdenjo
Copy link
Member Author

Fixed with @n1ru4l/[email protected].

@enisdenjo
Copy link
Member Author

Hmm, however, there is now another issue at hand. The error handling here: https://github.com/enisdenjo/graphiql/blob/4ed8102a0d8157ba1e89dc438e9236450cdd64b6/packages/graphiql-toolkit/src/create-fetcher/lib.ts#L99-L115

It worked following the recipe, but reverting back to using makeAsyncIterableIteratorFromSink broke it exactly as explained in #1827 (comment). (GraphiQL does not display any errors but the console says: Uncaught (in promise) Error: Socket closed with event 1011 jwt expired.)

I have no stack trace sadly, could there be an uncaught promise somewhere in push-pull-async-iterable-iterator @n1ru4l?

@enisdenjo
Copy link
Member Author

Note @n1ru4l, the iterator from makeAsyncIterableIteratorFromSink does not throw when calling sink.error.

@enisdenjo enisdenjo changed the title fix(ws): Simple async iterator for graphql-ws subscriptions and better error handling fix(ws): Subscriptions async iterator completes and better error handling Apr 19, 2021
@n1ru4l
Copy link
Collaborator

n1ru4l commented Apr 19, 2021

@enisdenjo https://github.com/n1ru4l/push-pull-async-iterable-iterator/releases/tag/v2.1.4 😰

@enisdenjo
Copy link
Member Author

Brilliant! Can confirm v2.1.4 working @n1ru4l.

@acao this is ready to merge now.

@n1ru4l
Copy link
Collaborator

n1ru4l commented Apr 19, 2021

Before merging please also reflect whether push-pull-async-iterable-iterator is a necessary dependency @acao 😇

@acao
Copy link
Member

acao commented Apr 21, 2021

Appreciate y’all putting so much into this already! Please ping me directly in the future if you have a PR ready for me as I have notifications disabled, and only tend to check on the weekends now that I’m still trying to take a break from maintaining

I don’t have time to look into whether or not that is a necessary dependency @n1ru4l , is it? Should we just merge and release this patch bugfix, and then drop it in a minor release as a follow up at least?

lastly can you... you actually created the changeset... 🥺😍 omg you guys are the best!

@acao acao merged commit 94f1695 into graphql:main Apr 21, 2021
@github-actions github-actions bot mentioned this pull request Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to unsubscribe from graphql-ws subscription
3 participants