immobiliare / RealHTTP

🌀swift async http client - fast, lightweight, type-safe
MIT License
282 stars 28 forks source link

[Bug]: Use of unimplemented 'init(request:cachedResponse:client:)' in RealHTTP.HTTPStubURLProtocol #61

Closed malcommac closed 2 years ago

malcommac commented 2 years ago

Platform Version

Any

SDK Version

Any

Xcode Version

Any

Steps To Reproduce

It's not always reproducible, but typically, it happens at the startup.

The error is:

RealHTTP/HTTPStubURLProtocol.swift:18: Fatal error: Use of unimplemented initializer 'init(request:cachedResponse:client:)' for class 'RealHTTP.HTTPStubURLProtocol'
(lldb) 

Expected Behavior

Init continue w/o crash

Actual Incorrect Behavior

Crash of the hosted app.

malcommac commented 2 years ago

Solution to this bug is to implement the callback and call super:

  // Occasionally called by iOS, even though init(task:...) is implemented. Will cause a crash if not present.
  override init(request: URLRequest, cachedResponse: CachedURLResponse?, client: URLProtocolClient?) {
     super.init(request: request, cachedResponse: cachedResponse, client: client)
  }