admin管理员组文章数量:1327945
Firefox 62.0.2 (64 bit). Windows 7 x64. Write code from this in firebase-messaging-sw.js of our site:
self.addEventListener('notificationclick', event => {
event.waitUntil(async function() {
throw "1";//this line for debug only
}());
});
Code raise exception "InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable" in Firefox on the event.waitUntil(). In Chrome work normally. Why? How I can fix it?
P.S. I am looking for the answer of the second day. :(
Firefox 62.0.2 (64 bit). Windows 7 x64. Write code from this in firebase-messaging-sw.js of our site:
self.addEventListener('notificationclick', event => {
event.waitUntil(async function() {
throw "1";//this line for debug only
}());
});
Code raise exception "InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable" in Firefox on the event.waitUntil(). In Chrome work normally. Why? How I can fix it?
P.S. I am looking for the answer of the second day. :(
Share Improve this question edited Jun 20, 2020 at 9:12 CommunityBot 11 silver badge asked Sep 30, 2018 at 7:11 Alexandr ShchetininAlexandr Shchetinin 931 silver badge9 bronze badges 3- so this is in a service worker, correct? – Jaromanda X Commented Sep 30, 2018 at 7:45
- Yes, it is service worker – Alexandr Shchetinin Commented Sep 30, 2018 at 7:48
- Did you find a fix? Getting this issue with a Vimeo player. – Alex Lacayo Commented Nov 8, 2018 at 8:51
1 Answer
Reset to default 6Had this problem in Firefox 63. And in Chrome everything is working fine. My service-worker code was:
importScripts('https://www.gstatic./firebasejs/5.5.6/firebase-app.js');
importScripts('https://www.gstatic./firebasejs/5.5.6/firebase-messaging.js');
firebase.initializeApp({
'messagingSenderId': '...'
});
var messaging = firebase.messaging();
self.addEventListener('notificationclick', function (event) {
...
}
I accidentally found this: stopImmediatePropagation in firebase-messaging.js. I moved my event-listener in the beginning of my service-worker (before importScripts):
self.addEventListener('notificationclick', function (event) {
...
}
importScripts('https://www.gstatic./firebasejs/5.5.6/firebase-app.js');
importScripts('https://www.gstatic./firebasejs/5.5.6/firebase-messaging.js');
And the handler started working in Firefox.
P.S. Handler started working fine, but after this manipulation the error was thrown by firebase-messaging library. event.stopImmediatePropagation() helped:
self.addEventListener('notificationclick', function (event) {
event.stopImmediatePropagation();
...
}
本文标签:
版权声明:本文标题:javascript - Firefox. InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable - Stack Overf 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742251510a2440849.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论