Whenever I react to a message, it crashes my program giving the following error:
Unhandled rejection URIError: URI malformed
at decodeURIComponent (<anonymous>)
at parsePackets (/Library/WebServer/Documents/Group-Management-FB-Bot/node_modules/facebook-chat-api/src/listen.js:185:35)
at Array.forEach (<anonymous>)
at /Library/WebServer/Documents/Group-Management-FB-Bot/node_modules/facebook-chat-api/src/listen.js:109:12
at tryCatcher (/Library/WebServer/Documents/Group-Management-FB-Bot/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/Library/WebServer/Documents/Group-Management-FB-Bot/node_modules/bluebird/js/main/promise.js:510:31)
at Promise._settlePromiseAt (/Library/WebServer/Documents/Group-Management-FB-Bot/node_modules/bluebird/js/main/promise.js:584:18)
at Promise._settlePromises (/Library/WebServer/Documents/Group-Management-FB-Bot/node_modules/bluebird/js/main/promise.js:700:14)
at Async._drainQueue (/Library/WebServer/Documents/Group-Management-FB-Bot/node_modules/bluebird/js/main/async.js:123:16)
at Async._drainQueues (/Library/WebServer/Documents/Group-Management-FB-Bot/node_modules/bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues (/Library/WebServer/Documents/Group-Management-FB-Bot/node_modules/bluebird/js/main/async.js:15:14)
at runCallback (timers.js:781:20)
at tryOnImmediate (timers.js:743:5)
at processImmediate [as _immediateCallback] (timers.js:714:5)
However, removing a reaction from a message still works.
The code I'm using looks something like this:
fb({email: username, password: password}, (err, api) => {
api.setOptions({listenEvents: true});
api.listen((err, event) => {
if(err) throw err;
console.log(event);
if(event.type === "message"){
// do some stuff
}
});
});
Whenever I react to a message, it crashes my program giving the following error:
Does this mean when you use api.setMessageReaction or when you react to something in the browser? I'm guessing you mean the latter but just want to check.
Looks like the problem is here... Could you add a line right before the call to globalCallback printing out the value of delta.deltaMessageReaction.reaction? I'm pretty sure the escape function has been deprecated so hopefully we can update that to something that makes more sense regardless (encodeURI or encodeURIComponent probably).
I'm reacting in the browser, sorry for not specifying. The value of delta.deltaMessageReaction.reaction was the emoji sent in the reaction (e.g. 馃槷) and escaping it returned a string looking like %uD83D%uDE2E.
Removing decodeURIComponent() and escape() from the line you linked to actually seemed to fix the error
It's cool that it's working without them, though I'm a little confused because those were originally added to fix #445...
Maybe facebook added something on their end. I'm considering removing them again. I would have also thought there would be more people complaining if the api was crashing on all reactions...
hehe, I'm complaining!!
@bearbear12345 thanks for confirming the issue
@gamelaster does it seem to you like facebook changed the behaviour on their end or is there some edge case we're missing here?
Ok seeing as this is crashing people I'm removed it for now and we can add something back in later if necessary.
Most helpful comment
Ok seeing as this is crashing people I'm removed it for now and we can add something back in later if necessary.