Title: [264838] trunk/Source/WebCore
- Revision
- 264838
- Author
- [email protected]
- Date
- 2020-07-24 10:18:20 -0700 (Fri, 24 Jul 2020)
Log Message
Monitor the case of a fetch event not able to register to the respondWith promise
https://bugs.webkit.org/show_bug.cgi?id=214631
Reviewed by Alex Christensen.
In some cases, the "Fetch event is destroyed" error is received.
One possibility is that the fetch event is not able to register to its respondWith promise.
Add a specific error message for that case.
This is difficult to test as we would need to have a fetch event trying to register to the respondWith promise
exactly at the time the service worker gets stopped.
* bindings/js/JSDOMPromise.cpp:
(WebCore::DOMPromise::whenSettled):
(WebCore::DOMPromise::whenPromiseIsSettled):
* bindings/js/JSDOMPromise.h:
* workers/service/FetchEvent.cpp:
(WebCore::FetchEvent::respondWith):
Change from weakThis to makeRef. While this is not strictly needed since addExtendLifetimePromise ref the event while calling whenSettled,
this is clearer and more robust.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (264837 => 264838)
--- trunk/Source/WebCore/ChangeLog 2020-07-24 17:15:26 UTC (rev 264837)
+++ trunk/Source/WebCore/ChangeLog 2020-07-24 17:18:20 UTC (rev 264838)
@@ -1,5 +1,28 @@
2020-07-24 Youenn Fablet <[email protected]>
+ Monitor the case of a fetch event not able to register to the respondWith promise
+ https://bugs.webkit.org/show_bug.cgi?id=214631
+
+ Reviewed by Alex Christensen.
+
+ In some cases, the "Fetch event is destroyed" error is received.
+ One possibility is that the fetch event is not able to register to its respondWith promise.
+ Add a specific error message for that case.
+
+ This is difficult to test as we would need to have a fetch event trying to register to the respondWith promise
+ exactly at the time the service worker gets stopped.
+
+ * bindings/js/JSDOMPromise.cpp:
+ (WebCore::DOMPromise::whenSettled):
+ (WebCore::DOMPromise::whenPromiseIsSettled):
+ * bindings/js/JSDOMPromise.h:
+ * workers/service/FetchEvent.cpp:
+ (WebCore::FetchEvent::respondWith):
+ Change from weakThis to makeRef. While this is not strictly needed since addExtendLifetimePromise ref the event while calling whenSettled,
+ this is clearer and more robust.
+
+2020-07-24 Youenn Fablet <[email protected]>
+
ASSERT(!m_peerConnection.isClosed()) on imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-operations.https.html
https://bugs.webkit.org/show_bug.cgi?id=214189
<rdar://problem/65343941>
Modified: trunk/Source/WebCore/bindings/js/JSDOMPromise.cpp (264837 => 264838)
--- trunk/Source/WebCore/bindings/js/JSDOMPromise.cpp 2020-07-24 17:15:26 UTC (rev 264837)
+++ trunk/Source/WebCore/bindings/js/JSDOMPromise.cpp 2020-07-24 17:18:20 UTC (rev 264838)
@@ -38,12 +38,12 @@
namespace WebCore {
-void DOMPromise::whenSettled(std::function<void()>&& callback)
+auto DOMPromise::whenSettled(std::function<void()>&& callback) -> IsCallbackRegistered
{
- whenPromiseIsSettled(globalObject(), promise(), WTFMove(callback));
+ return whenPromiseIsSettled(globalObject(), promise(), WTFMove(callback));
}
-void DOMPromise::whenPromiseIsSettled(JSDOMGlobalObject* globalObject, JSC::JSObject* promise, Function<void()>&& callback)
+auto DOMPromise::whenPromiseIsSettled(JSDOMGlobalObject* globalObject, JSC::JSObject* promise, Function<void()>&& callback) -> IsCallbackRegistered
{
auto& lexicalGlobalObject = *globalObject;
auto& vm = lexicalGlobalObject.vm();
@@ -59,7 +59,7 @@
EXCEPTION_ASSERT(!scope.exception() || isTerminatedExecutionException(lexicalGlobalObject.vm(), scope.exception()));
if (scope.exception())
- return;
+ return IsCallbackRegistered::No;
ASSERT(thenFunction.isCallable(vm));
@@ -72,6 +72,7 @@
call(&lexicalGlobalObject, thenFunction, callData, promise, arguments);
EXCEPTION_ASSERT(!scope.exception() || isTerminatedExecutionException(lexicalGlobalObject.vm(), scope.exception()));
+ return scope.exception() ? IsCallbackRegistered::No : IsCallbackRegistered::Yes;
}
JSC::JSValue DOMPromise::result() const
Modified: trunk/Source/WebCore/bindings/js/JSDOMPromise.h (264837 => 264838)
--- trunk/Source/WebCore/bindings/js/JSDOMPromise.h 2020-07-24 17:15:26 UTC (rev 264837)
+++ trunk/Source/WebCore/bindings/js/JSDOMPromise.h 2020-07-24 17:18:20 UTC (rev 264838)
@@ -44,13 +44,14 @@
return guarded();
}
- void whenSettled(std::function<void()>&&);
+ enum class IsCallbackRegistered { No, Yes };
+ IsCallbackRegistered whenSettled(std::function<void()>&&);
JSC::JSValue result() const;
enum class Status { Pending, Fulfilled, Rejected };
Status status() const;
- static void whenPromiseIsSettled(JSDOMGlobalObject*, JSC::JSObject* promise, Function<void()>&&);
+ static IsCallbackRegistered whenPromiseIsSettled(JSDOMGlobalObject*, JSC::JSObject* promise, Function<void()>&&);
private:
DOMPromise(JSDOMGlobalObject& globalObject, JSC::JSPromise& promise)
Modified: trunk/Source/WebCore/workers/service/FetchEvent.cpp (264837 => 264838)
--- trunk/Source/WebCore/workers/service/FetchEvent.cpp 2020-07-24 17:15:26 UTC (rev 264837)
+++ trunk/Source/WebCore/workers/service/FetchEvent.cpp 2020-07-24 17:18:20 UTC (rev 264838)
@@ -75,9 +75,7 @@
m_respondPromise = WTFMove(promise);
addExtendLifetimePromise(*m_respondPromise);
- m_respondPromise->whenSettled([this, weakThis = makeWeakPtr(*this)] () {
- if (!weakThis)
- return;
+ auto isRegistered = m_respondPromise->whenSettled([this, protectedThis = makeRef(*this)] {
promiseIsSettled();
});
@@ -87,6 +85,9 @@
m_respondWithEntered = true;
m_waitToRespond = true;
+ if (isRegistered == DOMPromise::IsCallbackRegistered::No)
+ respondWithError(createResponseError(m_request->url(), "FetchEvent unable to handle respondWith promise."_s));
+
return { };
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes