Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression on v1.4.6 #402

Closed
sonic555gr opened this issue Apr 30, 2019 · 10 comments
Closed

Regression on v1.4.6 #402

sonic555gr opened this issue Apr 30, 2019 · 10 comments

Comments

@sonic555gr
Copy link

Hello! I am experiencing a regression on v1.4.6.

Consider the following code.

// Path Declaration
var path: String {
        switch self {
        case .postOnboardingDocCheckFinishSuccess:
            return "onboarding/doc-check/finish"
        case .postOnboardingDocCheckStartSuccess:
            return "onboarding/doc-check/start"
        default:
            return "onboarding"
        }
    }
// Path registration
enum Method {
    case DELETE
    case PATCH
    case HEAD
    case POST
    case GET
    case PUT
}

protocol EndPoint {
    var method: Method { get }
    var path: String { get }
    var response: ((HttpRequest) -> HttpResponse) { get }
}

protocol JSONFileRepresentable {
    var fileName: String { get }
}

class Router {
    let server: HttpServer
    
    init() {
        server = HttpServer()
    }
    
    func stop() {
        server.stop()
    }
    
    func start() {
        try! server.start()
    }
    
    func setUp(with endPoints: [EndPoint]) {
        endPoints.forEach({
            switch $0.method {
            case .GET:
                server.GET[$0.path] = $0.response
            case .POST:
                server.POST[$0.path] = $0.response
            case .PUT:
                server.PUT[$0.path] = $0.response
            case .DELETE:
                server.DELETE[$0.path] = $0.response
            default:
                fatalError("Method not yet supported")
            }
        })
    }
}

Registering only Onboarding success. Calls the response block normally.
But registering all 3 paths makes onboarding to return 404 not found.
This is part of a testing suite and it started falling after updating to v1.4.6

It works fine on v1.4.5

@Vkt0r
Copy link
Member

Vkt0r commented Apr 30, 2019

Hey, @sonic555gr Thanks for reporting this! Can you please try your issue pointing to stable? We worked in a fix for two similar issues two weeks ago.

@sonic555gr
Copy link
Author

Hello @Vkt0r.
I installed "stable" branch but it seems to be failing on a different issue now.
I can't test the same problem since the tests fail much earlier.
Apparently the GET requests return status code of -1 and no response body.

@sonic555gr
Copy link
Author

sonic555gr commented Apr 30, 2019

I'm also sending you the Charles Session of one of the requests with the faulty response.

[
   {
      "status":"COMPLETE",
      "method":"GET",
      "protocolVersion":"HTTP/1.1",
      "scheme":"http",
      "host":"localhost",
      "port":8080,
      "actualPort":8080,
      "path":"/user/details",
      "query":null,
      "tunnel":false,
      "keptAlive":false,
      "webSocket":false,
      "remoteAddress":"localhost/127.0.0.1",
      "clientAddress":"/127.0.0.1",
      "clientPort":53409,
      "times":{
         "start":"2019-04-30T15:06:25.684+01:00",
         "requestBegin":"2019-04-30T15:06:25.688+01:00",
         "requestComplete":"2019-04-30T15:06:25.688+01:00",
         "responseBegin":"2019-04-30T15:06:25.690+01:00",
         "end":"2019-04-30T15:06:25.690+01:00"
      },
      "durations":{
         "total":5,
         "dns":2,
         "connect":1,
         "ssl":null,
         "request":0,
         "response":0,
         "latency":2
      },
      "speeds":{
         "overall":"93400",
         "request":"0",
         "response":"0"
      },
      "totalSize":"467",
      "request":{
         "sizes":{
            "headers":342,
            "body":0
         },
         "mimeType":null,
         "charset":null,
         "contentEncoding":null,
         "header":{
            "firstLine":"GET /user/details HTTP/1.1",
            "headers":[
               {
                  "name":"Host",
                  "value":"localhost:8080"
               },
               {
                  "name":"X-Device-Fingerprint",
                  "value":"A fingerprint"
               },
               {
                  "name":"Accept",
                  "value":"*/*"
               },
               {
                  "name":"User-Agent",
                  "value":"PagoFX/1.0+2975 x86_64 iOS/12.2 CFNetwork/978.0.7 Darwin/18.2.0"
               },
               {
                  "name":"Authorization",
                  "value":"A BEARER"
               },
               {
                  "name":"Accept-Language",
                  "value":"en-us"
               },
               {
                  "name":"Accept-Encoding",
                  "value":"gzip, deflate"
               },
               {
                  "name":"Connection",
                  "value":"keep-alive"
               }
            ]
         }
      },
      "response":{
         "status":-1,
         "sizes":{
            "headers":62,
            "body":63
         },
         "mimeType":null,
         "charset":null,
         "contentEncoding":null,
         "header":{
            "firstLine":null,
            "headers":[

            ]
         },
         "body":{
            "text":"HTTP/1.1 8103229482974933605 Created\r\nServer: Swifter 1.3.3\r\n\r\n",
            "charset":null
         }
      }
   }
]

@Vkt0r
Copy link
Member

Vkt0r commented May 1, 2019

Hey, @sonic555gr Thanks for the Charles response! Nevertheless, I'm seeing something weird in your response just in the following line:

"body": {
    "text":"HTTP/1.1 8103229482974933605 Created\r\nServer: Swifter 1.3.3\r\n\r\n",
     "charset":null
 }

As you can see above we set the version of the server is being used and your response is telling me you're using the version 1.3.3. If you're using Cocoapods or Carthage you need to specify the stable branch.

Below you can see the Charles session response from a test I have in my current PR and compare with yours:

 
[
    {
        "status": "COMPLETE",
        "method": "GET",
        "protocolVersion": "HTTP/1.1",
        "scheme": "http",
        "host": "localhost",
        "port": 8080,
        "actualPort": 8080,
        "path": "/a/:b/c",
        "query": null,
        "tunnel": false,
        "keptAlive": true,
        "webSocket": false,
        "remoteAddress": "localhost/127.0.0.1",
        "clientAddress": "/127.0.0.1",
        "clientPort": 51015,
        "times": {
            "start": "2019-04-30T23:03:45.517-04:00",
            "requestBegin": "2019-04-30T23:03:45.518-04:00",
            "requestComplete": "2019-04-30T23:03:45.518-04:00",
            "responseBegin": "2019-04-30T23:03:45.519-04:00",
            "end": "2019-04-30T23:03:45.519-04:00"
        },
        "durations": {
            "total": 1,
            "dns": null,
            "connect": null,
            "ssl": null,
            "request": 0,
            "response": 0,
            "latency": 1
        },
        "speeds": {
            "overall": "396000",
            "request": "0",
            "response": "0"
        },
        "totalSize": "396",
        "request": {
            "sizes": {
                "headers": 200,
                "body": 0
            },
            "mimeType": null,
            "charset": null,
            "contentEncoding": null,
            "header": {
                "firstLine": "GET /a/:b/c HTTP/1.1",
                "headers": [
                    {
                        "name": "Host",
                        "value": "localhost:8080"
                    },
                    {
                        "name": "Accept",
                        "value": "*/*"
                    },
                    {
                        "name": "User-Agent",
                        "value": "xctest/14490.71 CFNetwork/978.0.7 Darwin/18.5.0"
                    },
                    {
                        "name": "Accept-Language",
                        "value": "en-us"
                    },
                    {
                        "name": "Accept-Encoding",
                        "value": "gzip, deflate"
                    },
                    {
                        "name": "Connection",
                        "value": "keep-alive"
                    }
                ]
            }
        },
        "response": {
            "status": 200,
            "sizes": {
                "headers": 127,
                "body": 69
            },
            "mimeType": "text/html",
            "charset": null,
            "contentEncoding": null,
            "header": {
                "firstLine": "HTTP/1.1 200 OK",
                "headers": [
                    {
                        "name": "Content-Length",
                        "value": "69"
                    },
                    {
                        "name": "Server",
                        "value": "Swifter 1.4.6"
                    },
                    {
                        "name": "Content-Type",
                        "value": "text/html"
                    },
                    {
                        "name": "Proxy-Connection",
                        "value": "keep-alive"
                    }
                ]
            }
        }
    }
]
  

As you can see the version of the server should reflect 1.4.6.

@sonic555gr
Copy link
Author

sonic555gr commented May 1, 2019

It was definitely the right branch I pulled from cocoapods
pod 'Swifter', :git => 'git@github.com:httpswift/swifter.git', :branch => 'stable'

@Vkt0r
Copy link
Member

Vkt0r commented May 1, 2019

@sonic555gr Can you please set the following line in your Podfile:

pod 'Swifter', :git => 'git@github.com:httpswift/swifter.git', :branch => 'stable'

Afterward, run pod update Swifter in your terminal and try again your issue

If the above steps don't work for you I going to need you to create a sample project reproducing your issue if that's possible.

@sonic555gr
Copy link
Author

@Vkt0r I will do it again, but this is what I'm doing. and That is the response I'm getting. I will enclose the entire session from charles and tomorrow do some debugging on my tests and try to get closer to the problem, maybe pull swifter and write some tests that replicated the problem.

@Vkt0r
Copy link
Member

Vkt0r commented May 1, 2019

Thanks, @sonic555gr That would be great, keep me posted!

@sonic555gr
Copy link
Author

Spend a bit of time on it. And found the issue. After adding "stable" as a development pod and trying to breakpoint my way through the problem I realised that the breakpoints weren't working. Derived data was somehow corrupted after updating the Swifter pod and while it kept working it was using some obscure version of the Swifter library (I don't even have 1.3.3 installed). I was flabbergasted to know that this can occur. There was no indication whatsoever that something was wrong and The results where random and inconsistent.

"Stable" branch seems to have the issue fixed. I will keep 1.4.5 as my stable version till you push 1.4.7. Thank you very much.

@Vkt0r
Copy link
Member

Vkt0r commented May 2, 2019

@sonic555gr Thanks for reporting your results. Glad to hear your problem is solved in the stable branch. We will be releasing a new version very soon 🚀 !

@Vkt0r Vkt0r closed this as completed May 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants