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: onSubscribeError should be invoked #3196

Merged
merged 17 commits into from
Mar 12, 2024
Merged

fix: onSubscribeError should be invoked #3196

merged 17 commits into from
Mar 12, 2024

Conversation

n1ru4l
Copy link
Collaborator

@n1ru4l n1ru4l commented Mar 8, 2024

I noticed that the onSubscribeError error hook is not invoked due to how graphql-tools/executor does execution.

See ardatan/graphql-tools#5965, for the prerequisite changes with in tools/executor

Copy link

changeset-bot bot commented Mar 8, 2024

🦋 Changeset detected

Latest commit: b16074b

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

This PR includes changesets to release 24 packages
Name Type
graphql-yoga Minor
@graphql-yoga/nestjs Major
@graphql-yoga/render-graphiql Major
@graphql-yoga/plugin-apollo-inline-trace Major
@graphql-yoga/plugin-apq Major
@graphql-yoga/plugin-csrf-prevention Major
@graphql-yoga/plugin-defer-stream Major
@graphql-yoga/plugin-disable-introspection Major
@graphql-yoga/plugin-graphql-sse Major
@graphql-yoga/plugin-jwt Major
@graphql-yoga/plugin-persisted-operations Major
@graphql-yoga/plugin-prometheus Major
@graphql-yoga/plugin-response-cache Major
@graphql-yoga/plugin-sofa Major
apollo-federation-gateway-with-yoga Patch
apollo-subgraph-with-yoga Patch
graphql-lambda Patch
cloudflare-advanced Patch
cloudflare Patch
functions Patch
hackernews Patch
nextjs-app Patch
hello-world-benchmark Patch
@graphql-yoga/nestjs-federation 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

Copy link
Contributor

github-actions bot commented Mar 8, 2024

Apollo Federation Subgraph Compatibility Results

Federation 1 Support Federation 2 Support
_service🟢
@key (single)🟢
@key (multi)🟢
@key (composite)🟢
repeatable @key🟢
@requires🟢
@provides🟢
federated tracing🟢
@link🟢
@shareable🟢
@tag🟢
@override🟢
@inaccessible🟢
@composeDirective🟢
@interfaceObject🟢

Learn more:

Copy link
Contributor

github-actions bot commented Mar 8, 2024

💻 Website Preview

The latest changes are available as preview in: https://f7386c56.graphql-yoga.pages.dev

Copy link
Contributor

github-actions bot commented Mar 8, 2024

✅ Benchmark Results

     ✓ no_errors{mode:graphql}
     ✓ expected_result{mode:graphql}
     ✓ no_errors{mode:graphql-jit}
     ✓ expected_result{mode:graphql-jit}
     ✓ no_errors{mode:graphql-response-cache}
     ✓ expected_result{mode:graphql-response-cache}
     ✓ no_errors{mode:graphql-no-parse-validate-cache}
     ✓ expected_result{mode:graphql-no-parse-validate-cache}

     checks.......................................: 100.00% ✓ 406678      ✗ 0     
     data_received................................: 1.6 GB  14 MB/s
     data_sent....................................: 82 MB   684 kB/s
     http_req_blocked.............................: avg=1.45µs   min=952ns    med=1.3µs    max=4.58ms   p(90)=1.89µs   p(95)=2.09µs  
     http_req_connecting..........................: avg=2ns      min=0s       med=0s       max=130.88µs p(90)=0s       p(95)=0s      
     http_req_duration............................: avg=379.33µs min=205.42µs med=337.12µs max=16.54ms  p(90)=541.41µs p(95)=560.49µs
       { expected_response:true }.................: avg=379.33µs min=205.42µs med=337.12µs max=16.54ms  p(90)=541.41µs p(95)=560.49µs
     ✓ { mode:graphql-jit }.......................: avg=281.45µs min=205.42µs med=261.45µs max=14.51ms  p(90)=289.77µs p(95)=299.92µs
     ✓ { mode:graphql-no-parse-validate-cache }...: avg=566.82µs min=448.5µs  med=541.21µs max=11.68ms  p(90)=580.57µs p(95)=610.9µs 
     ✓ { mode:graphql-response-cache }............: avg=360.76µs min=287.59µs med=341.6µs  max=16.54ms  p(90)=370.88µs p(95)=380.58µs
     ✓ { mode:graphql }...........................: avg=375.27µs min=280.56µs med=343.99µs max=13.18ms  p(90)=383.47µs p(95)=424.73µs
     http_req_failed..............................: 0.00%   ✓ 0           ✗ 203339
     http_req_receiving...........................: avg=32.48µs  min=16.04µs  med=32.47µs  max=6.04ms   p(90)=38.23µs  p(95)=40.31µs 
     http_req_sending.............................: avg=8.17µs   min=5.6µs    med=7.32µs   max=3.99ms   p(90)=10.72µs  p(95)=11.36µs 
     http_req_tls_handshaking.....................: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting.............................: avg=338.68µs min=175.04µs med=297.21µs max=16.47ms  p(90)=500.74µs p(95)=517.57µs
     http_reqs....................................: 203339  1694.468931/s
     iteration_duration...........................: avg=585.49µs min=369.93µs med=540.04µs max=16.79ms  p(90)=750.97µs p(95)=773.13µs
     iterations...................................: 203339  1694.468931/s
     vus..........................................: 1       min=1         max=1   
     vus_max......................................: 2       min=2         max=2   

Copy link
Contributor

github-actions bot commented Mar 8, 2024

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
graphql-yoga-cloud-run-guide 3.2.0-alpha-20240312090652-b16074bb npm ↗︎ unpkg ↗︎
@graphql-yoga/apollo-link 3.2.0-alpha-20240312090652-b16074bb npm ↗︎ unpkg ↗︎
@graphql-yoga/urql-exchange 3.2.0-alpha-20240312090652-b16074bb npm ↗︎ unpkg ↗︎
graphql-yoga 5.2.0-alpha-20240312090652-b16074bb npm ↗︎ unpkg ↗︎
@graphql-yoga/nestjs 3.2.0-alpha-20240312090652-b16074bb npm ↗︎ unpkg ↗︎
@graphql-yoga/nestjs-federation 3.2.0-alpha-20240312090652-b16074bb npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-apollo-inline-trace 3.2.0-alpha-20240312090652-b16074bb npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-apq 3.2.0-alpha-20240312090652-b16074bb npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-csrf-prevention 3.2.0-alpha-20240312090652-b16074bb npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-defer-stream 3.2.0-alpha-20240312090652-b16074bb npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-disable-introspection 2.2.0-alpha-20240312090652-b16074bb npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-graphql-sse 3.2.0-alpha-20240312090652-b16074bb npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-jwt 2.2.0-alpha-20240312090652-b16074bb npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-persisted-operations 3.2.0-alpha-20240312090652-b16074bb npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-prometheus 4.1.0-alpha-20240312090652-b16074bb npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-response-cache 3.4.0-alpha-20240312090652-b16074bb npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-sofa 3.2.0-alpha-20240312090652-b16074bb npm ↗︎ unpkg ↗︎
@graphql-yoga/render-graphiql 5.2.0-alpha-20240312090652-b16074bb npm ↗︎ unpkg ↗︎

@n1ru4l n1ru4l changed the title test: failing subscription event stream fix: onSubscribeError should be invoked Mar 8, 2024
@@ -475,6 +476,32 @@ export class YogaServer<
this.logger.debug(`Processing GraphQL Parameters done.`);
}

/** Ensure that error thrown from subscribe is sent to client */
if (result && Symbol.asyncIterator in result) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't use isAsyncResult util we have ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The typing of this function is incorrect result can never be async iterable, if we want to do this change we need to refactor and fix the typings (which I will do ofc).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@EmrysMyrddin
Copy link
Collaborator

Why do we want to send internal event source errors to the client ? Shouldn't we just abort the connection at this point ?
Perhaps allowing cutom close code but I'm not sure if we should send the error ?

Is there and RFC for this ?

@n1ru4l
Copy link
Collaborator Author

n1ru4l commented Mar 9, 2024

Why do we want to send internal event source errors to the client ?

You could do an auth/access check that should be sent to the client for example.

There is unfortunately no RFC or clarity...

@n1ru4l n1ru4l merged commit 71db754 into main Mar 12, 2024
27 of 29 checks passed
@n1ru4l n1ru4l deleted the failing-test branch March 12, 2024 11:02
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.

3 participants