Bug 234002

Summary: Copy ServiceWorkerNavigationPreloader error when failing its ServiceWorkerFetchTask
Product: WebKit Reporter: youenn fablet <youennf>
Component: Service WorkersAssignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, cdumez, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description youenn fablet 2021-12-08 06:20:49 PST
Copy ServiceWorkerNavigationPreloader error when failing its ServiceWorkerFetchTask
Comment 1 youenn fablet 2021-12-08 06:25:11 PST
Created attachment 446356 [details]
Patch
Comment 2 Chris Dumez 2021-12-08 07:34:37 PST
Comment on attachment 446356 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=446356&action=review

> Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp:370
>          if (!m_preloader->error().isNull()) {

Maybe this would look better?
```
if (auto error = m_preloader->error(); !error.isNull()) {
    didFail(error);
    return;
}
```

> Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp:397
> +            didFail(ResourceError { m_preloader->error() });

ditto.
Comment 3 youenn fablet 2021-12-08 08:07:36 PST
Comment on attachment 446356 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=446356&action=review

>> Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp:370
>>          if (!m_preloader->error().isNull()) {
> 
> Maybe this would look better?
> ```
> if (auto error = m_preloader->error(); !error.isNull()) {
>     didFail(error);
>     return;
> }
> ```

I am not sure, I would tend to leave the comment in any case.
With your proposal, we would always copy the error, though a null error copy y is probably very cheap.
Another approach is to return a ResourceError and not a const ResourceError&, or a std::optional<ResourceError>.
Comment 4 EWS 2021-12-09 03:43:51 PST
Committed r286774 (245015@main): <https://commits.webkit.org/245015@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 446356 [details].
Comment 5 Radar WebKit Bug Importer 2021-12-09 03:44:27 PST
<rdar://problem/86263771>