I got "URI Malformed" errors in loop when I try to send reaction with your API.
Is this a known issue? (Using the npm version: 1.4)
ERR! listen URIError: URI malformed
ERR! listen at decodeURIComponent (native)
ERR! listen at parsePackets (/var/www/polybot/node_modules/facebook-chat-api/src/listen.js:185:35)
ERR! listen at Array.forEach (native)
ERR! listen at /var/www/polybot/node_modules/facebook-chat-api/src/listen.js:109:12
ERR! listen at tryCatcher (/var/www/polybot/node_modules/bluebird/js/main/util.js:26:23)
ERR! listen at Promise._settlePromiseFromHandler (/var/www/polybot/node_modules/bluebird/js/main/promise.js:510:31)
ERR! listen at Promise._settlePromiseAt (/var/www/polybot/node_modules/bluebird/js/main/promise.js:584:18)
ERR! listen at Promise._settlePromises (/var/www/polybot/node_modules/bluebird/js/main/promise.js:700:14)
ERR! listen at Async._drainQueue (/var/www/polybot/node_modules/bluebird/js/main/async.js:123:16)
ERR! listen at Async._drainQueues (/var/www/polybot/node_modules/bluebird/js/main/async.js:133:10)
ERR! listen at Immediate.Async.drainQueues [as _onImmediate] (/var/www/polybot/node_modules/bluebird/js/main/async.js:15:14)
ERR! listen at tryOnImmediate (timers.js:534:15)
ERR! listen at processImmediate [as _immediateCallback] (timers.js:514:5)
It seems to happen whenever a reaction is received too
The problem is that we call escape followed by decodeURIComponent. This seems useless but it may be a workaround for another issue.
escape turns emoji into "%uXXXX%uXXXX" - which is non-standard and makes decodeURIComponent fail. escape was deprecated but its replacement - encodeURIComponent - properly handles emoji and other more-than-1-byte-long unicode code points.
@Schmavery Is the decode(encode()) call really needed? If so, would using encodeURIComponent fit the bill?
On another note, when the library fails to parse one message it seems to keep retrying, blocking input from the outside world. We should probably have a error handler on a higher level with something like "if parsing fails, log it and go on to the next one".
@hraph @addobandre sorry everyone, this is my fault for not publishing a new npm version. This is fixed in master, afaik by #516. I will cut a new version later today if possible.
Ah missed that issue in my search. Sorry!
I get:
URIError: URI malformed
at decodeURIComponent (<anonymous>)
at parsePackets (/proj/node_modules/facebook-chat-api/src/listen.js:185:35)
at Array.forEach (<anonymous>)
at /proj/node_modules/facebook-chat-api/src/listen.js:109:12
at tryCatcher (/proj/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/proj/node_modules/bluebird/js/main/promise.js:510:31)
at Promise._settlePromiseAt (/proj/node_modules/bluebird/js/main/promise.js:584:18)
at Promise._settlePromises (/proj/node_modules/bluebird/js/main/promise.js:700:14)
at Async._drainQueue (/proj/node_modules/bluebird/js/main/async.js:123:16)
at Async._drainQueues (/proj/node_modules/bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues [as _onImmediate] (/proj/node_modules/bluebird/js/main/async.js:15:14)
at runCallback (timers.js:756:18)
at tryOnImmediate (timers.js:717:5)
at processImmediate [as _immediateCallback] (timers.js:697:5)
Should be fixed in version 1.5.0 on npm
Most helpful comment
@hraph @addobandre sorry everyone, this is my fault for not publishing a new npm version. This is fixed in master, afaik by #516. I will cut a new version later today if possible.