Closed djones6 closed 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?
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.
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 ..
@saiHemak this seems to be reported over Twitter too https://twitter.com/mxcl/status/1111073495017029635
session.taskRegistry.remove(task)
has been called twice once from urlProtocol(`protocol`, didFailWithError: urlError)
and the from the switch case case .dataCompletionHandler(let completion):
Please open an issue to track re-enabling these tests once Swift 5.0.1 ships with the fix.
Raised an issue to uncomment the tests here
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.