-
Notifications
You must be signed in to change notification settings - Fork 662
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
Parsing incoming WebSocket message fails with a SyntaxError
from invalid JSON
#2057
Comments
Thank you for catching this! I can confirm this behaviour as well 🤔 looking into it 🙇 |
I set up a test app that has a simple
The automatic bolt |
I was able to reproduce this issue in just the socket-mode client. I think it has to do with the fact the event listener for The web socket will raise a node-slack-sdk/packages/socket-mode/src/SlackWebSocket.ts Lines 126 to 128 in 943e153
|
I think I see the issue. First, a weird thing I noticed: why do Slack
Surely the backend doesn't send two events over the wire to an app? Sure enough, it has to do with the fact that the node-slack-sdk/packages/socket-mode/src/SocketModeClient.ts Lines 338 to 340 in 943e153
Essentially, if a Slack "event":{"type":"message"} So, effectively the current code consumes Slack |
Packages
@slack/socket-mode
Reproducible in
A setup similar to this:
Steps to reproduce
message
event subscription and listerExpected result
The event to be processed from a message handler and delivered to a
message
event lister 👀Actual result
Incoming events are ignored but it's also interesting that the connection is setup alright 🤔
Initial thoughts
The sent payloads seem valid but the strangeness might be happening in how these are converted from byte to string 👾
The code logging the most interesting parts above is below, and when making the change that follows I get an interesting output:
node-slack-sdk/packages/socket-mode/src/SocketModeClient.ts
Lines 284 to 291 in 943e153
Here is the interesting output
And I'm thinking the
ack
function might be doing something strange here 🤔 It's super interesting too that the message seems to be received as bytes then printed as a string? Confusing times.This section follows soon after too which makes some amount of parsing seem needed, which makes sense! I'm also not certain that it is the
ack
function causing this, but it does seem tricky if we are needing to parse this 👀node-slack-sdk/packages/socket-mode/src/SocketModeClient.ts
Lines 305 to 317 in 943e153
Requirements
For general questions/issues about Slack API platform or its server-side, could you submit questions at https://my.slack.com/help/requests/new instead. 🙇
Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.
The text was updated successfully, but these errors were encountered: