parseMessage (common.ts) throws and caches error on each socket message #395
FreeRiderBysik
started this conversation in
General
Replies: 2 comments
-
Hi, Looks really strange, especially if consider that stringify is forced on the server side: https://github.com/enisdenjo/graphql-ws/blob/master/src/server.ts#L691 https://github.com/enisdenjo/graphql-ws/blob/master/src/common.ts#L455 |
Beta Was this translation helpful? Give feedback.
0 replies
-
@FreeRiderBysik you're absolutely right, the parsing was too convoluted. I pushed a fix following you suggestion and have released it with v5.10.2. Thanks for investigating and making a suggestion! Would appreciate it if you could try again and report any other discrepancies. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using graphql-ws with uWebSockets and @urql.
I discovered tons of errors like
Message is expected to be an object, but got string
, then launching debugger(Stack is: onmessage->parseMessage->validateMessage).
So, my socket messages are strings, it working correct. Now parseMessage looks like:
So it will throw Error and then catch it every time it got string. It is antipattern (exception as flow control) and it can effect performance.
I suppose it will be simpler and work better with something like this:
Beta Was this translation helpful? Give feedback.
All reactions