Getting registration ID for the project

715 views
Skip to first unread message

Deepak Mani

unread,
Aug 31, 2014, 10:21:05 AM8/31/14
to gcm-for-chr...@googlegroups.com
Hello,

I'm trying to register my extension using:

var senderIds = ["My Project Number"]; // I think that my project ID is valid. Can this be verified.

chrome.gcm.register(senderIds, registerCallback);


I'm not sure what steps to take to debug this error:

"Error:Asynchronous operation is pending. "

I'm calling this method inside:
chrome.runtime.onInstalled.addListener(function() and not on chrome.runtime.onStartup.addListener(function() as mentioned in the docs.

Thank you,
Deepak 

Filip Gorski

unread,
Sep 1, 2014, 2:57:10 PM9/1/14
to gcm-for-chr...@googlegroups.com
Hi, Deepak,

The error message you are getting indicates that you are calling registration or unregistration multiple times, before letting the previous execution finish (at which point the callback would be issued).
Only one register or unregister call can be issued at a time, and the operation is dependent on network conditions (it will make the call multiple times with exponential backoff for you, when your connection is intermittent). After several retries it will give up, but it can happen minutes later.

Could you make sure that your code is only called once?

Also, do you re-install your application often, and if so, did you try to restart Chrome ( I am thinking of a case where there would be a callback pending, but the application is long gone.)

Thanks.
Filip

Filip Gorski

unread,
Sep 2, 2014, 1:59:31 PM9/2/14
to gcm-for-chr...@googlegroups.com
Hi, Deepak,

Posting a follow up here, as people might run into that issue.
 
Hey Filip,
Thanks for the message. 
1.I restarted chrome and when I loaded the extension only once, it does not show the previous error. However, after running chrome.gcm.register the registerCallback method does not seem get called. My network connection is working.
2. In the Google API's console I have enabled Google Cloud Messaging for Chrome. Is there anything else that needs to be done here?
Following https://developer.chrome.com/apps/cloudMessaging#enable_the_gcm_service, you are using permission for the chrome.pushMessaging API, while you really want Google Cloud Messaging for Android

Enable the GCM service

  1. In the sidebar on the left, select APIs & auth.
  2. In the displayed list of APIs, turn the Google Cloud Messaging for Android toggle to ON.

 
3. I checked that the "registered" key is not stored in chrome. 
4. The manifest is version 2 and has 'gcm' in the permissions.
<< code samples omitted >>

Everything else seems to check out in your code.

Let me know if you still experience problems, and please post to the group so that others can benefit.

Thanks.
Filip

Deepak Mani

unread,
Sep 4, 2014, 7:39:17 AM9/4/14
to gcm-for-chr...@googlegroups.com
Hi Filip,

1. I am still not getting chrome.gcm.register("project_num", callbackMethod) to call the callback function after enabling 'GCM for Android'. 

2. It is a bit confusing why we need to use 'GCM for Android' when there is a 'GCM for Chrome'. Is GCM for Android also used for Desktop Chrome instances?

3. Can I use the push_messaging API  (since I'm able to get the Channel ID) or will that be deprecated? 

Thanks,
Deepak

Filip Gorski

unread,
Sep 4, 2014, 11:59:00 AM9/4/14
to gcm-for-chr...@googlegroups.com
Hi, Deepak,

I'll be looking into it. More answers inline.

Do you still get "async operation pending"?

Thanks.
Filip


On Thursday, September 4, 2014 4:39:17 AM UTC-7, Deepak Mani wrote:
Hi Filip,

1. I am still not getting chrome.gcm.register("project_num", callbackMethod) to call the callback function after enabling 'GCM for Android'. 
 I'll take another look at the code you sent, and may ask you some more questions. Later today.

2. It is a bit confusing why we need to use 'GCM for Android' when there is a 'GCM for Chrome'. Is GCM for Android also used for Desktop Chrome instances?
 chrome.gcm uses shared infrastructure based on the GCM for Android.
GCM for Chrome is a permission for chrome.pushMessaging.

3. Can I use the push_messaging API  (since I'm able to get the Channel ID) or will that be deprecated? 
You should not use chrome.pushMessaging API. It is deprecated: http://blog.chromium.org/2014/09/moving-towards-single-cloud-messaging.html
You should not be able upload a new app with pushMessaging permission by now.

Keven Wang

unread,
Apr 8, 2015, 9:50:12 PM4/8/15
to gcm-for-chr...@googlegroups.com
I'm also getting this "Asynchronous Operation is Pending" error intermittently on gcm.unregister(). It seems to happen on Macbook Air. The WIFI condition is stable. I will collect more information and post it here.

Filip Gorski

unread,
Apr 9, 2015, 4:51:52 PM4/9/15
to gcm-for-chr...@googlegroups.com
Keven,

Please post what version of chrome you are running.
Also, how does gcm.register behave? Do you see the same error? 

Thanks.
Filip

Keven Wang

unread,
Apr 9, 2015, 9:05:34 PM4/9/15
to Filip Gorski, gcm-for-chr...@googlegroups.com
Hi Filip,

The versions are: 

41.0.2272.118
41.0.2272.89

This is happening with unregister(). In my code, I actually do an unregister() first, and in the callback I do register(). I can try to see if register() works.

--
You received this message because you are subscribed to a topic in the Google Groups "GCM for Chrome feedback" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gcm-for-chrome-feedback/upfZVv3mcjk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gcm-for-chrome-fe...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Keven

Keven Wang

unread,
Apr 14, 2015, 12:34:38 AM4/14/15
to Filip Gorski, gcm-for-chr...@googlegroups.com
register() call fails with "Asynchronous Operation is Pending" as well. I recall seeing this problem before. Uninstall / reinstalling Chrome fixed it.

Is there a way to clear all in-flight asynchronous operations in Chrome? Would that fix this issue?
--

Keven

Filip Gorski

unread,
Apr 14, 2015, 1:05:02 PM4/14/15
to gcm-for-chr...@googlegroups.com
Hi, Keven,

Sorry for late response. I am not sure what was a reason of the problem. We did fix a similar issue https://code.google.com/p/chromium/issues/detail?id=371880 and relevant code is present in Chrome 41. I wonder, if calling register from unregister callback has something to do with it.
Perhaps your error showed up before M41 and then your Chrome was updated, but the store was in corrupt state.
I think we added logic that fixes the GCM Store in case of corruption after Chrome 41. For future, to reset GCM for a profile, go to that profile's folder and delete GCM Store folder.

Thanks.
Filip
--

Keven



--

Keven

Keven Wang

unread,
Apr 14, 2015, 1:14:24 PM4/14/15
to Filip Gorski, gcm-for-chr...@googlegroups.com
Sounds good for the reply Filip! I will try these steps.

Thanks Deepak as well!

--
You received this message because you are subscribed to a topic in the Google Groups "GCM for Chrome feedback" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gcm-for-chrome-feedback/upfZVv3mcjk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gcm-for-chrome-fe...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Keven

Deepak Mani

unread,
May 4, 2015, 3:57:58 AM5/4/15
to Filip Gorski, gcm-for-chr...@googlegroups.com

Hi Keven,

Did you get it working?

Also, how do you clear the GCM store programmatically if a user  has this issue or uninitialized state as I saw in my case.
If a user is not signed in can GCM be made to work?

Thanks,
Deepak

--

Filip Gorski

unread,
May 4, 2015, 12:28:10 PM5/4/15
to gcm-for-chr...@googlegroups.com, fgo...@chromium.org
Hi, Deepak,

To answer your questions:
* There is no way to clear the GCM store other than deleting the GCM Store folder from Profile.
* You can use GCM without user being signed in. You simply need to have a single registration, before GCM is initialized.

Thanks.
Filip

Keven Wang

unread,
May 4, 2015, 3:20:45 PM5/4/15
to Filip Gorski, gcm-for-chr...@googlegroups.com
As an update, this issue is resolved for me.

Both users have state == UNINITIALIZED on chrome://gcm-internals page They were able to successfully call chrome.gcm.register(), after signing out of Chrome, and signing back in.

--
You received this message because you are subscribed to a topic in the Google Groups "GCM for Chrome feedback" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gcm-for-chrome-feedback/upfZVv3mcjk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gcm-for-chrome-fe...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Keven

Aishwarya Adiga

unread,
May 25, 2016, 8:50:03 PM5/25/16
to GCM for Chrome feedback, fgo...@chromium.org
Hi,

I am facing a similar issue. "Asynchronous operation pending" when I try to register. It was working fine until a few days ago. To resolve this, I have uninstalled chrome / restarted it- still the same error. Is there a way to cancel all asynchronous operations?

Please tell me how to proceed.
To unsubscribe from this group and all its topics, send an email to gcm-for-chrome-feedback+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Keven

Filip Gorski

unread,
May 27, 2016, 1:44:10 AM5/27/16
to GCM for Chrome feedback, fgo...@chromium.org
Hi, Aishwarya,

Is it possible that your code is actually calling register/unregister (or combination thereof) twice without waiting for the result of a previous call? That would be the case which yields that error message. 

Thanks.
Filip

Aishwarya Adiga

unread,
Jun 1, 2016, 12:40:02 AM6/1/16
to GCM for Chrome feedback, fgo...@chromium.org
Hi Filip,

I checked my code again. Register is being called only once. The same code works perfectly fine on my colleagues laptop. Only on my laptop , this issue persists. Is there any way to cancel all pending asynchronous operations?

Thanks,
Aishwarya

Filip Gorski

unread,
Jun 1, 2016, 12:45:43 PM6/1/16
to GCM for Chrome feedback, fgo...@chromium.org
Hi, Aishwarya,

I there is no way to reset all pending request. I am wondering what might be different about your laptop. Did you visit chrome://gcm-internals ? What is the connection state?

Feel free to contact me directly if you don't want to share any of the information on the forum.
Also is there a chance you are reusing your Chrome profile folder in multiple places or restoring it?

Thanks.
Filip

Filip Gorski

unread,
Jun 8, 2016, 3:50:36 PM6/8/16
to GCM for Chrome feedback, fgo...@chromium.org
Hi, Aishwarya,

I've just answered a somewhat related question on SO: http://stackoverflow.com/questions/37661572/google-chrome-gcm-registration-doesnt-work/37685029#37685029
I know that suggestion like this was proposed above, but perhaps deleting the store is a thing you could try.

Thanks.
Filip

loly...@gmail.com

unread,
Sep 17, 2016, 8:11:58 PM9/17/16
to GCM for Chrome feedback
Hi! 
with FCM registerCallback method also does not seem get called. How does it work with FCM?

четвер, 4 вересня 2014 р. 18:59:00 UTC+3 користувач Filip Gorski написав:

loly...@gmail.com

unread,
Sep 17, 2016, 8:13:45 PM9/17/16
to GCM for Chrome feedback

Hi! 
with FCM registerCallback method also does not seem get called. How does it work with FCM?
неділя, 31 серпня 2014 р. 17:21:05 UTC+3 користувач Deepak Mani написав:

Keven Wang

unread,
Oct 19, 2016, 7:12:39 PM10/19/16
to GCM for Chrome feedback, fgo...@chromium.org
We have seen an increase in this "Asynchronous operation is pending" error recently. We have received 10+ support tickets in the last 6 weeks.

The register() and deregister() call are not fired in parallel.

Deleting GCM Store folder fixes the issue.

@Filip: Just want to flag, as this issue appears to be happening more frequently.
Reply all
Reply to author
Forward
0 new messages