ToothlessGear / node-gcm

A NodeJS wrapper library port to send data to Android devices via Google Cloud Messaging
https://github.com/ToothlessGear/node-gcm
Other
1.31k stars 206 forks source link

sendMessage callback called multiple times #122

Closed KATT closed 9 years ago

KATT commented 9 years ago

Because of retry count (most likely) the callback when using send() is called multiple times.

hypesystem commented 9 years ago

Can you give some more details on when this happens? What code did you run? What was the exact output?

KATT commented 9 years ago

The issue actually didn't end up being in node-gcm, but I'm gonna do a PR with a small change.

From: sender.js#L102-L107

        try {
            callback(null, JSON.parse(resBody));
        } catch (e) {
            debug("Error handling GCM response " + e);
            callback("error", null);
        }

I had an exception being thrown in my callback of send which ended up causing a loop of retries and the callback ended up getting called, then throwing an error, then getting called again, then throwing an error .. until retryCount was reached.

PR coming up to take the callback out of the try/catch.

hypesystem commented 9 years ago

Great catch! This is obviously a problem :)