Kitura / KituraKit

Swift client library for using Codable routes with Kitura
Apache License 2.0
59 stars 20 forks source link

CI failure with Swift 5 #45

Closed djones6 closed 5 years ago

djones6 commented 5 years ago

42 aims to add Swift 5 testing to the CI, but one of the tests fails on Linux with:

/home/travis/build/IBM-Swift/KituraKit/Tests/KituraKitTests/BasicAuthTests.swift:90: error: BasicAuthTests.testBasicAuthUnauthorized : XCTAssertEqual failed: ("601 : A connection error occurred, cannot connect to the server. Please ensure that the server is started and running, with the correct port and URL ('ToDoServer' if using the sample app).") is not equal to ("401 : Unauthorized") - Fatal error: Trying to remove task, but it's not in the registry.: file /home/buildnode/jenkins/workspace/oss-swift-5.0-package-linux-ubuntu-16_04/swift-corelibs-foundation/Foundation/URLSession/TaskRegistry.swift, line 76 /home/travis/build/IBM-Swift/KituraKit/Tests/KituraKitTests/BasicAuthTests.swift:91: error: BasicAuthTests.testBasicAuthUnauthorized : API violation - multiple calls made to XCTestExpectation.fulfill() for A response is received from the server -> .unauthorized. Exited with signal code 4

This needs investigation.

djones6 commented 5 years ago

@Andrew-Lees11 could you document the double invocation of the callback you found from URLSession.dataTask when Kitura sends a 401: Unauthorized response? And also link to the StackOverflow issue you found which is likely to be the same / related to this.

I wonder if this is somehow related to https://github.com/apple/swift-corelibs-foundation/pull/1569 - in which case maybe @saiHemak could investigate?

Andrew-Lees11 commented 5 years ago

I created a gist that would recreate the test failure here.

When a Kitura server returns a 401 unauthorized code the callback on URLSession.dataTask is called twice. once with "The operation could not be completed" and then with the response from Kitura. This is not true for other error codes and only happens on Swift 5 on Linux.

I think This Stackoverflow error May be running into the same problem since it is only failing on Linux but i'm not entirely sure.

saiHemak commented 5 years ago

Could successfully recreate the issue from TestFoundation. Upon instrumenting the code I could see the TaskRegistry.remove is getting called twice . Instrumenting further to identify why the remove call has been triggered twice ..

pushkarnk commented 5 years ago

@saiHemak this seems to be reported over Twitter too https://twitter.com/mxcl/status/1111073495017029635

saiHemak commented 5 years ago

session.taskRegistry.remove(task) has been called twice once from urlProtocol(`protocol`, didFailWithError: urlError) and the from the switch case case .dataCompletionHandler(let completion):

saiHemak commented 5 years ago

created PR https://github.com/apple/swift-corelibs-foundation/pull/2061

ianpartridge commented 5 years ago

Please open an issue to track re-enabling these tests once Swift 5.0.1 ships with the fix.

Andrew-Lees11 commented 5 years ago

Raised an issue to uncomment the tests here