Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

FB require_delivery: Remove use of message.delivery.mids because not guaranteed #1312

Merged
merged 1 commit into from
Apr 30, 2018

Conversation

cchan
Copy link
Contributor

@cchan cchan commented Apr 4, 2018

Fixes #1311

@benbrown
Copy link
Contributor

benbrown commented Apr 6, 2018

@cchan can you help me understand how to test this?

@cchan
Copy link
Contributor Author

cchan commented Apr 11, 2018

@benbrown That's an interesting question; I'm not sure how testing works for botkit. Do you have mocks set up for Facebook?

@cchan cchan closed this Apr 11, 2018
@cchan cchan reopened this Apr 11, 2018
@cchan
Copy link
Contributor Author

cchan commented Apr 11, 2018

(oops)

@cchan
Copy link
Contributor Author

cchan commented Apr 12, 2018

@benbrown Hm, could we create a sinon test similar to this existing one? I'm not familiar at all with how botkit works internally, but it seems like there's a polling loop that checks if the previous message has been marked as delivered before sending the next one. We could... somehow hook into that and make sure messages are returned back in order?

@benbrown
Copy link
Contributor

@cchan my original comment probably confused the issue. what I need to know is what settings to enable and what type of events I need to trigger in order to see this fix in action.

@benbrown benbrown closed this Apr 12, 2018
@benbrown benbrown reopened this Apr 12, 2018
@cchan
Copy link
Contributor Author

cchan commented Apr 13, 2018

@benbrown Ah, that's what you mean. You just need to set require_delivery: true and send a bunch of messages in a row from Botkit - that's pretty much it. Facebook will respond with delivery events, but once in a while the response will not contain the field mids, which crashes the old code.

I haven't been able to figure out what conditions cause Facebook to not provide mids in the response, but after you try it for enough times / long enough it'll just happen, seemingly at random. I think it's probably a load reduction feature on Facebook's end - the "delivered" feature is probably fundamentally based on the watermark timestamp, and when they don't have the capacity to generate the corresponding list of message IDs, they simply don't.

(The reason I found this bug is that I have a bot on my server (clive-io/statbot) that monitors logs et cetera, and it was crashing at random about once a week.)

@RJiryes
Copy link

RJiryes commented Apr 21, 2018

Hey is this going to be merged anytime soon? Great catch @cchan ;-)

@benbrown benbrown merged commit 410e87a into howdyai:master Apr 30, 2018
@benbrown
Copy link
Contributor

@cchan @RJiryes merged!

@cchan
Copy link
Contributor Author

cchan commented Apr 30, 2018

Awesome! :D

@RJiryes
Copy link

RJiryes commented May 2, 2018

@benbrown Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants