Closed chrissexton closed 7 years ago
The error is 'EOF' from Slack. Forever ago with github.com/velour/relay, I was seeing periodic disconnects from Slack. We never solved it and I just ended up running it in a restart loop.
We should solve it now.
On the other hand, the error could be something totally different, and the EOF could be a red herring. We cancel all Channels on the bridge when something fails. When we close the receivers, Receive will send EOF. Maybe we are reporting that EOF instead of the actual error.
Ah, but the serialization error is coming from the Slack close call. That's definitely the cause.
Let's add better logging of json errors. We should capture the message data in a bytes.Buffer, decode it from there, and on error print the data and error offset.
A very similar error happened again today (I'm assuming it's the same-ish cause) when I edited my Slack profile.
2017/01/11 11:03:08 Bridge closed with error: failed to receive from velour on hashvelour.slack.com: EOF
panic: json: cannot unmarshal object into Go value of type chat.UserID
goroutine 1 [running]:
panic(0x676cc0, 0xc4203efd40)
/home/cws/go/src/runtime/panic.go:500 +0x1a1
main.main.func3(0xc4200b6960, 0x813400, 0xc420010380)
/home/cws/src/github.com/velour/chat/bridge/main.go:100 +0x7e
main.main()
/home/cws/src/github.com/velour/chat/bridge/main.go:162 +0x1197
2017/01/11 11:03:14 Bridge is up and running.
2017/01/11 11:03:14 Connecting:
2017/01/11 11:03:14 #velour on IRC (irc.freenode.net:6697)
2017/01/11 11:03:14 #velour on Telegram
2017/01/11 11:03:14 velour on hashvelour.slack.com
Message{
ID: "1484150512.017484"
From: User{
ID: "U0RLUDELD"
Nick: "flyngpngn"
FullName: "The Hammer"
DisplayName: "flyngpngn"
PhotoURL: "https://secure.gravatar.com/avatar/ff57b3a83dcae3ee96233e2f47906ef6.jpg?s=192&d=https%!A(MISSING)%!F(MISSI
NG)%!F(MISSING)a.slack-edge.com%!F(MISSING)7fa9%!F(MISSING)img%!F(MISSING)avatars%!F(MISSING)ava_0015-192.png"
}
Text: "I think I know what that error is about"
}
2017/01/11 11:03:57 Bridge closed with error: failed to receive from velour on hashvelour.slack.com: EOF
panic: json: cannot unmarshal object into Go value of type chat.UserID
goroutine 1 [running]:
panic(0x676cc0, 0xc420390450)
/home/cws/go/src/runtime/panic.go:500 +0x1a1
main.main.func3(0xc4200b6960, 0x813400, 0xc420010380)
/home/cws/src/github.com/velour/chat/bridge/main.go:100 +0x7e
main.main()
/home/cws/src/github.com/velour/chat/bridge/main.go:162 +0x1197
good find!
Actually, these may be separate issues. One is trying to unmarshall an object into a string, and the other into a chat.UserID.
Basically the problem is that each event type returned by the RTM API can have a different return. We always assume that it will be structured like Update
; that assumption is wrong.
In the case of "type":"user_change"
, for example, the "user"
field is an object; Update
assumes that it's as string.
We received this crash: