Skip to content

fix(subs): allow additional server variations (e.g., Tls, Http2)#4200

Merged
abernix merged 5 commits into
apollographql:mainfrom
braineo:fix-ws-check
Aug 13, 2020
Merged

fix(subs): allow additional server variations (e.g., Tls, Http2)#4200
abernix merged 5 commits into
apollographql:mainfrom
braineo:fix-ws-check

Conversation

@braineo

@braineo braineo commented Jun 4, 2020

Copy link
Copy Markdown
Contributor

fix #4198

Refer to discussion in the issue please.

@apollo-cla

Copy link
Copy Markdown

@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
Copy Markdown
Contributor

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

@braineo

braineo commented Jun 9, 2020

Copy link
Copy Markdown
Contributor Author

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

jedwards1211 commented Jun 9, 2020

Copy link
Copy Markdown
Contributor

@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

braineo commented Jun 11, 2020

Copy link
Copy Markdown
Contributor Author

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

@braineo

braineo commented Jun 17, 2020

Copy link
Copy Markdown
Contributor Author

@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

braineo commented Jun 22, 2020

Copy link
Copy Markdown
Contributor Author

@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
Copy Markdown
Contributor

?

@abernix

abernix commented Jun 24, 2020

Copy link
Copy Markdown
Member

Unintentional closing! Please stand-by: #4304

@jedwards1211

Copy link
Copy Markdown
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

@abernix abernix left a comment

Copy link
Copy Markdown
Member

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

braineo commented Jun 26, 2020

Copy link
Copy Markdown
Contributor Author

@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

braineo commented Jul 10, 2020

Copy link
Copy Markdown
Contributor Author

@abernix

I added test for websocket server.

@braineo

braineo commented Aug 3, 2020

Copy link
Copy Markdown
Contributor Author

@abernix Ping

@braineo

braineo commented Aug 12, 2020

Copy link
Copy Markdown
Contributor Author

@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