Http request does not work on ios 15

Every http request fails on ios 15 native device or emulator with the following error

{"headers":{"normalizedNames":{},"lazyUpdate":null,"headers":{}},"status":0,"statusText":"Unknown Error","url":"[i removed the url]","ok":false,"name":"HttpErrorResponse","message":"Http failure response for [i removed the url] : 0 Unknown Error","error":{"isTrusted":true}}

I’m using @angular/common/http it works file with all previous ios versions ( tried 13 latest , 14 latest - it’s just fine - server returns the required CORS headers, etc)

( i know there’s native and capacitor http plugins, but the app relies heavily on this implementation with angular and observables )

Anyone else have this problem? Anyone knows what to do?

My env data:

Ionic:

   Ionic CLI                     : 6.16.3 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 6.0.0-dev.202106282030.9f3b1d9
   @angular-devkit/build-angular : 12.1.1
   @angular-devkit/schematics    : 12.1.1
   @angular/cli                  : 12.1.1
   @ionic/angular-toolkit        : 4.0.0

Capacitor:

   Capacitor CLI      : 3.0.2
   @capacitor/android : 3.0.2
   @capacitor/core    : 3.0.2
   @capacitor/ios     : 3.0.2

Utility:

   cordova-res : not installed globally
   native-run  : 1.4.0

System:

   NodeJS : v16.4.0 (/usr/local/bin/node)
   npm    : 7.19.0
   OS     : macOS Big Sur

Xcode:

   13.0 beta

Ios version:

   15.0 beta

There is a note in the iOS 15 beta 2 release notes about deprecation of cleartext HTTP for proxy configuration. Any chance it applies to your situation?

Tnx for the quick reply, but I don’t think it’s the case … we’re hitting a secure (https) url

I would think the proxy configuration would be a separate concern from the ultimate URL, but if you aren’t using PAC, then maybe it’s irrelevant.

I dug into system logs on iphone, and found this

0x104df6000 - NetworkCORSPreflightChecker::didComplete, AccessControl error: Origin  is not allowed by Access-Control-Allow-Origin.
0x104b9ba00 - NetworkLoadChecker::checkCORSRequestWithPreflight - makeCrossOriginAccessRequestWithPreflight preflight complete, success=0 forRedirect=0
0x104dfa380 - [pageProxyID=5, webPageID=6, frameID=3, resourceID=99, isMainResource=0, destination=0, isSynchronous=0] NetworkResourceLoader::start: NetworkLoadChecker::check returned an error (error.domain=WebKitInternal, error.code=0, isCancellation=0)
0x104dfa380 - [pageProxyID=5, webPageID=6, frameID=3, resourceID=99, isMainResource=0, destination=0, isSynchronous=0] NetworkResourceLoader::start: NetworkLoadChecker::check returned an error (error.domain=WebKitInternal, error.code=0, isCancellation=0)

really looks like a CORS problem, not sure what have changed in ios 15 … digging …

I’ll keep an eye on this, but it’s worth noting that ios 15 is still in beta and is likely to have bugs.

Thanks! I really hope apple sorts this out. I made a bunch or experiments with server side CORS related headers, and also - just to make sure - tried to hit some 3ty party open api endpoints ( to be sure that it’s not a server side CORS problem ) and the result is the same. So, probably iOS 15 and/or WebKit realted … for now I think I’ll go back to previous version, and hope that I’ll be able to use angular’s http client, because if I have to switch to ionic-native or capacitor http, then it will be a real pain :slight_smile:

here’s a simple code snippet if anyone wants to test. just create a blank ionic project, compile it and test it on ios 15 beta

import { HttpClient } from '@angular/common/http'

...
test() {
    this.httpclient.get('https://jsonplaceholder.typicode.com/users/1').subscribe({
      next: (data)=>{
        console.log(data);
      },
      error: (err)=>{
        console.error(err);
      }});
}

result in xcode debug console:

⚡️  [error] - {"headers":{"normalizedNames":{},"lazyUpdate":null,"headers":{}},"status":0,"statusText":"Unknown Error","url":"https://jsonplaceholder.typicode.com/users/1","ok":false,"name":"HttpErrorResponse","message":"Http failure response for https://jsonplaceholder.typicode.com/users/1: 0 Unknown Error","error":{"isTrusted":true}}

I did get a different result in system logs so

error in system console:

default	21:58:11.776071+0200	com.apple.WebKit.Networking	0x103128000 - [webProcessIdentifier=4] NetworkConnectionToWebProcess::scheduleResourceLoad: (parentPID=897, pageProxyID=5, webPageID=6, frameID=3, resourceID=24)
default	21:58:11.776272+0200	com.apple.WebKit.Networking	0x103128000 - [webProcessIdentifier=4] NetworkConnectionToWebProcess::resolveBlobReferences: (parentPID=897, pageProxyID=5, webPageID=6, frameID=3, resourceID=24)
default	21:58:11.776361+0200	com.apple.WebKit.Networking	0x10334e080 - [pageProxyID=5, webPageID=6, frameID=3, resourceID=24, isMainResource=0, destination=0, isSynchronous=0] NetworkResourceLoader::startWithServiceWorker:
default	21:58:11.776408+0200	com.apple.WebKit.Networking	0x10334e080 - [pageProxyID=5, webPageID=6, frameID=3, resourceID=24, isMainResource=0, destination=0, isSynchronous=0] NetworkResourceLoader::serviceWorkerDidNotHandle: (fetchIdentifier=0)
default	21:58:11.776477+0200	com.apple.WebKit.Networking	0x10334e080 - [pageProxyID=5, webPageID=6, frameID=3, resourceID=24, isMainResource=0, destination=0, isSynchronous=0] NetworkResourceLoader::start: hasNetworkLoadChecker=1
default	21:58:11.776559+0200	com.apple.WebKit.Networking	0x10334e080 - [pageProxyID=5, webPageID=6, frameID=3, resourceID=24, isMainResource=0, destination=0, isSynchronous=0] NetworkResourceLoader::start: NetworkLoadChecker::check is done
default	21:58:11.776632+0200	com.apple.WebKit.Networking	0x10334e080 - [pageProxyID=5, webPageID=6, frameID=3, resourceID=24, isMainResource=0, destination=0, isSynchronous=0] NetworkResourceLoader::retrieveCacheEntry: isMainFrameLoad=0
default	21:58:11.776704+0200	com.apple.WebKit.Networking	0x10334e080 - [pageProxyID=5, webPageID=6, frameID=3, resourceID=24, isMainResource=0, destination=0, isSynchronous=0] NetworkResourceLoader::retrieveCacheEntry: Checking the HTTP disk cache
default	21:58:11.777667+0200	com.apple.WebKit.Networking	0x10334e080 - [pageProxyID=5, webPageID=6, frameID=3, resourceID=24, isMainResource=0, destination=0, isSynchronous=0] NetworkResourceLoader::retrieveCacheEntry: Done checking the HTTP disk cache (foundCachedEntry=1)
default	21:58:11.777761+0200	com.apple.WebKit.Networking	0x10334e080 - [pageProxyID=5, webPageID=6, frameID=3, resourceID=24, isMainResource=0, destination=0, isSynchronous=0] NetworkResourceLoader::retrieveCacheEntryInternal:
default	21:58:11.777832+0200	com.apple.WebKit.Networking	0x10334e080 - [pageProxyID=5, webPageID=6, frameID=3, resourceID=24, isMainResource=0, destination=0, isSynchronous=0] NetworkResourceLoader::retrieveCacheEntryInternal: Cached entry needs revalidation
default	21:58:11.777901+0200	com.apple.WebKit.Networking	0x10334e080 - [pageProxyID=5, webPageID=6, frameID=3, resourceID=24, isMainResource=0, destination=0, isSynchronous=0] NetworkResourceLoader::validateCacheEntry:
default	21:58:11.777956+0200	com.apple.WebKit.Networking	0x10334e080 - [pageProxyID=5, webPageID=6, frameID=3, resourceID=24, isMainResource=0, destination=0, isSynchronous=0] NetworkResourceLoader::startNetworkLoad: (isFirstLoad=1, timeout=2147483647.000000)
default	21:58:11.778007+0200	com.apple.WebKit.Networking	Task <489CAB19-6348-4CE9-8B24-34FD50B59F1F>.<6> resuming, timeouts(2147483647.0, 604800.0) QOS(0x19) Voucher (null)
default	21:58:11.778459+0200	com.apple.WebKit.Networking	[Telemetry]: Activity <nw_activity 12:2 [4EA69AD6-5F62-451B-8100-F8D3880F4BE5] (reporting strategy default)> on Task <489CAB19-6348-4CE9-8B24-34FD50B59F1F>.<6> was not selected for reporting
default	21:58:11.778552+0200	com.apple.WebKit.Networking	0x10334e080 - [pageProxyID=5, webPageID=6, frameID=3, resourceID=24, isMainResource=0, destination=0, isSynchronous=0] NetworkResourceLoader::startNetworkLoad: Going to the network (description=LocalDataTask <489CAB19-6348-4CE9-8B24-34FD50B59F1F>.<6>)
default	21:58:11.779129+0200	com.apple.WebKit.Networking	Task <489CAB19-6348-4CE9-8B24-34FD50B59F1F>.<6> {strength 0, tls 4, ct 0, sub 0, sig 1, ciphers 0, bundle 0, builtin 0}
default	21:58:11.779407+0200	com.apple.WebKit.Networking	Task <489CAB19-6348-4CE9-8B24-34FD50B59F1F>.<6> now using Connection 2
default	21:58:11.779848+0200	com.apple.WebKit.Networking	Task <489CAB19-6348-4CE9-8B24-34FD50B59F1F>.<6> sent request, body N 0
default	21:58:11.838782+0200	com.apple.WebKit.Networking	Task <489CAB19-6348-4CE9-8B24-34FD50B59F1F>.<6> received response, status 304 content U
default	21:58:11.838938+0200	com.apple.WebKit.Networking	Task <489CAB19-6348-4CE9-8B24-34FD50B59F1F>.<6> done using Connection 2
default	21:58:11.839320+0200	com.apple.WebKit.Networking	Task <489CAB19-6348-4CE9-8B24-34FD50B59F1F>.<6> response ended
default	21:58:11.839762+0200	com.apple.WebKit.Networking	0x10334e080 - [pageProxyID=5, webPageID=6, frameID=3, resourceID=24, isMainResource=0, destination=0, isSynchronous=0] NetworkResourceLoader::didReceiveResponse: (httpStatusCode=304, MIMEType=, expectedContentLength=-1, hasCachedEntryForValidation=1, hasNetworkLoadChecker=1)
default	21:58:11.839870+0200	com.apple.WebKit.Networking	0x10334e080 - [pageProxyID=5, webPageID=6, frameID=3, resourceID=24, isMainResource=0, destination=0, isSynchronous=0] NetworkResourceLoader::didReceiveResponse: Received revalidation response (validationSucceeded=1, wasOriginalRequestConditional=0)
default	21:58:11.840219+0200	com.apple.WebKit.Networking	Task <489CAB19-6348-4CE9-8B24-34FD50B59F1F>.<6> summary for task success {transaction_duration_ms=61, response_status=304, connection=2, reused=1, request_start_ms=0, request_duration_ms=0, response_start_ms=59, response_duration_ms=0, request_bytes=57, response_bytes=293, cache_hit=0}
default	21:58:11.840320+0200	com.apple.WebKit.Networking	Task <489CAB19-6348-4CE9-8B24-34FD50B59F1F>.<6> finished successfully
default	21:58:11.840821+0200	com.apple.WebKit.Networking	0x10334e080 - [pageProxyID=5, webPageID=6, frameID=3, resourceID=24, isMainResource=0, destination=0, isSynchronous=0] NetworkResourceLoader::didFinishLoading: (numBytesReceived=0, hasCacheEntryForValidation=1)
default	21:58:11.840890+0200	com.apple.WebKit.Networking	0x10334e080 - [pageProxyID=5, webPageID=6, frameID=3, resourceID=24, isMainResource=0, destination=0, isSynchronous=0] NetworkResourceLoader::didRetrieveCacheEntry:
error	21:58:11.841238+0200	com.apple.WebKit.Networking	0x10334e080 - [pageProxyID=5, webPageID=6, frameID=3, resourceID=24, isMainResource=0, destination=0, isSynchronous=0] NetworkResourceLoader::didRetrieveCacheEntry: Failing load due to NetworkLoadChecker::validateResponse
error	21:58:11.841314+0200	com.apple.WebKit.Networking	0x10334e080 - [pageProxyID=5, webPageID=6, frameID=3, resourceID=24, isMainResource=0, destination=0, isSynchronous=0] NetworkResourceLoader::didFailLoading: (wasServiceWorkerLoad=0, isTimeout=0, isCancellation=0, isAccessControl=1, errorCode=0)
default	21:58:11.841428+0200	com.apple.WebKit.Networking	0x10334e080 - [pageProxyID=5, webPageID=6, frameID=3, resourceID=24, isMainResource=0, destination=0, isSynchronous=0] NetworkResourceLoader::cleanup: (result=2)
default	21:58:16.787166+0200	com.apple.WebKit.Networking	automatic index on z(sourceDomainID)

same code run on ios 13 for example results:

⚡️  [log] - {"id":1,"name":"Leanne Graham","username":"Bret","email":"Sincere@april.biz","address":{"street":"Kulas Light","suite":"Apt. 556","city":"Gwenborough","zipcode":"92998-3874","geo":{"lat":"-37.3159","lng":"81.1496"}},"phone":"1-770-736-8031 x56442","website":"hildegard.org","company":{"name":"Romaguera-Crona","catchPhrase":"Multi-layered client-server neural-net","bs":"harness real-time e-markets"}}

Do you have access to the server-side logs? It would be interesting to help disambiguate what is going on over the wire versus what is Webkit talking to itself.

I’m especially keen on knowing what’s going on with that 304 in your last post. The error message suggests that NetworkLoadChecker::validateResponse is failing, but the way I read the source (which may be out of date), that method actually punts to somebody else in the specific case of CORS on 304s.

So I want to know:

  • was there really a request that went over the wire that your server returned a 304 for?
  • was there a previous request for that same resource?
  • did it succeed?
  • what did the CORS preflight look like (if any) on that first load?
  • what CORS-related headers were returned on the 304 itself? (assuming the 304 actually happened outside of WebKit’s mind)

Sorry, the last log is for the placeholder api server - I have no access to the logs - I just wanted to make sure that it’s not our server’s headers that causing the problem ( I mean it works fine with previous versions so probably not, but just in case ) - maybe it wasn’t the best example to attach here.

FYI: 226760 – Origin is null in http requests when baseURL has custom scheme on iOS 15.0

3 Likes

Neat, very likely related. Thanks!