-
Notifications
You must be signed in to change notification settings - Fork 2k
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
subscription server not properly initialized when taking websocket.Server #4198
Comments
There was a recent PR, #1966, that aimed to support this. Perhaps you could look at that and see if there is a bug in the implementation? |
hi @abernix I think I'm looking exactly on this change. I made some change here to check if server is a http server. I would guess because both my application and apollo server has
and due to node_module resolving algorithm, What do you think? |
To example my hypothesis I did experiment in the transpile js file //node_modules/apollo-server-core/dist/ApolloServer.js
const ws_1 = __importDefault(require("ws"));
const ws_2 = __importDefault(require("../../ws"));
/// ...
installSubscriptionHandlers(server) {
console.error("Whats my wss2? is it instanceof apollo's WebSocketServer?", server instanceof ws_1.default.Server);
console.error("Whats my wss2? is it instanceof my's WebSocketServer??", server instanceof ws_2.default.Server) And I got following prints
|
@jedwards1211 Thoughts on this and the PR? |
Yeah sounds like a duplicate module issue. Maybe we could use some check besides |
Braineo's solution is pretty smart, since native modules (http) wouldn't suffer instanceof issues Edit: probably should check for https too though? I forget if the class is different for https |
The only other thing I would suggest is to support passing |
@braineo I just ran into the same problem where I was using
Was all that was required to make it work and I finally started seeing subscription messages coming through again. The instanceof doesn't work as you can't guarantee it coming from the same module. What would be a good simple robust change for a pull request, reading through the |
@braineo & others, the patch that is in the other issue is typescript, the current repo is mostly just Javascript so here is a gist with a working patch in just Javascript https://gist.github.com/timkock/b38ae86cf5634c63dc482c7fc1c66be1 |
What happens
I have an express server running multiple websockets and I'm adding a graphql endpoint with subscription to it.
I found
installSubscriptionHandlers
took a WebsocketServer but I didn't get any notification, but passing a http server toinstallSubscriptionHandlers
worksI found
subscriptions-transport-ws
does not think I'm passing a websocket server on this linehttps://github.com/apollographql/subscriptions-transport-ws/blob/master/src/server.ts#L132
And actually it received
I used TypeScript and I try to print my argument out in transpiled js files
Here I got
here I got
It does not make sense to me, or is it a common gotcha of
instanceof
?deps
"apollo-server-core": "2.13.1",
The text was updated successfully, but these errors were encountered: