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(subs): allow additional server variations (e.g., Tls, Http2) #4200

Merged
merged 5 commits into from
Aug 13, 2020

Conversation

braineo
Copy link
Contributor

@braineo braineo commented Jun 4, 2020

fix #4198

Refer to discussion in the issue please.

@apollo-cla
Copy link

@braineo: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

@jedwards1211
Copy link
Contributor

Seems like we should check for HttpsServer and Http2Server as well?

@braineo
Copy link
Contributor Author

braineo commented Jun 9, 2020

Hi @jedwards1211 I have not checked if https or http2 server are supported. Just reading from the function signature typing and seems it only take http.Server

https://github.com/apollographql/apollo-server/blob/master/packages/apollo-server-core/src/ApolloServer.ts#L595

import { Server as HttpServer } from 'http';
/// code
  public installSubscriptionHandlers(server: HttpServer | WebSocket.Server) 

@jedwards1211
Copy link
Contributor

jedwards1211 commented Jun 9, 2020

@abernix I'm guessing when using just JS it's possible to pass an https.Server or http2.Server? Maybe we should add those to the type defs?

@braineo
Copy link
Contributor Author

braineo commented Jun 11, 2020

@jedwards1211 Let me know what do you think. Should be easy to add.

@braineo
Copy link
Contributor Author

braineo commented Jun 17, 2020

@jedwards1211 @abernix

Ok I added type of http2 servers too. Just http2 module does not expose the class constructor that we cannot use isInstanceof

alternatively I used net.Server and tls.Server, what do you think?

As for the CI, it says

FAIL  packages/apollo-gateway/src/__tests__/integration/networkRequests.test.ts (5.838s)
  ● Downstream service health checks › Managed mode › Rolls over to new schema when health check succeeds

    : Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Timeout

I am not sure if it is a bug or just time out

@braineo braineo force-pushed the fix-ws-check branch 2 times, most recently from 41ad161 to 5a8753d Compare June 22, 2020 13:05
@braineo
Copy link
Contributor Author

braineo commented Jun 22, 2020

@jedwards1211 @abernix

Seems the master branch is failing the same test and probably not introduced by this PR. Would you review or comment anything so that we can merge this PR soon please?

@abernix abernix closed this Jun 24, 2020
@jedwards1211
Copy link
Contributor

?

@abernix
Copy link
Member

abernix commented Jun 24, 2020

Unintentional closing! Please stand-by: #4304

@jedwards1211
Copy link
Contributor

gotcha, I see hump day decided to celebrate for you

@abernix abernix reopened this Jun 25, 2020
@abernix abernix changed the base branch from master to main June 25, 2020 09:01
Copy link
Member

@abernix abernix left a comment

Choose a reason for hiding this comment

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

I think this looks good, but can we write a number of test cases that exercise these types of servers with installSubscriptionHandlers?

@braineo
Copy link
Contributor Author

braineo commented Jun 26, 2020

@abernix where will be the best place to add?

inside packages/apollo-server-integration-testsuite/src/ApolloServer.ts and add more like this but ignore the httpServer pass down from a Promise?

        createApolloServer({
          typeDefs,
          resolvers,
        }).then(({ port, server, httpServer }) => {
          server.installSubscriptionHandlers(httpServer);

@braineo
Copy link
Contributor Author

braineo commented Jul 10, 2020

@abernix

I added test for websocket server.

@braineo
Copy link
Contributor Author

braineo commented Aug 3, 2020

@abernix Ping

@braineo
Copy link
Contributor Author

braineo commented Aug 12, 2020

@abernix Ping

@abernix abernix changed the title Fix server type check fix(subs): allow additional server variations (e.g., Tls) Aug 13, 2020
@abernix abernix changed the title fix(subs): allow additional server variations (e.g., Tls) fix(subs): allow additional server variations (e.g., Tls, Http2) Aug 13, 2020
@abernix abernix added this to the Release 2.17.0 milestone Aug 13, 2020
@abernix abernix merged commit 8ab0e90 into apollographql:main Aug 13, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 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.

subscription server not properly initialized when taking websocket.Server
4 participants