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

Add Upload Request Timeout, Fix API Error Messages #230

Merged
merged 10 commits into from
Sep 17, 2024

Conversation

tobitech
Copy link
Contributor

@tobitech tobitech commented Sep 11, 2024

Story: https://app.shortcut.com/smileid/story/13466/

Summary

  • Add a new argument for SmileID initialiser to specify timeout for upload requests.
  • Refactor upload method to use async await instead of AsyncThrowingStream.
  • Handle URLError and show localizedDescription to users.

Known Issues

Confirm that timeout errors are handled.

Test Instructions

  • In HomeViewModel add a short uploadRequestTimeout argument to the SmileID initialiser like 1sec.
  • Run a job that involves upload requests
  • The job should time out.

Screenshot

https://portal.usesmileid.com/admin/job/production/172668761

@tobitech tobitech self-assigned this Sep 11, 2024
@tobitech tobitech requested a review from a team as a code owner September 11, 2024 12:22
Copy link

github-actions bot commented Sep 11, 2024

Warnings
⚠️ The source files were changed, but the tests remain unmodified. Consider updating or adding to the tests to match the source changes.
⚠️

Sources/SmileID/Classes/BiometricKYC/OrchestratedBiometricKycViewModel.swift#L72 - Function should have complexity 10 or less: currently complexity equals 11 (cyclomatic_complexity)

⚠️

Sources/SmileID/Classes/BiometricKYC/OrchestratedBiometricKycViewModel.swift#L126 - TODOs should be resolved (- Fix when Michael changes thi...). (todo)

⚠️

Sources/SmileID/Classes/DocumentVerification/Model/OrchestratedDocumentVerificationViewModel.swift#L109 - Function should have complexity 10 or less: currently complexity equals 14 (cyclomatic_complexity)

⚠️

Sources/SmileID/Classes/DocumentVerification/Model/OrchestratedDocumentVerificationViewModel.swift#L196 - TODOs should be resolved (- Fix when Michael changes thi...). (todo)

⚠️

Sources/SmileID/Classes/DocumentVerification/Model/OrchestratedDocumentVerificationViewModel.swift#L315 - Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)

⚠️

Sources/SmileID/Classes/SmileID.swift#L30 - Line should be 120 characters or less: currently 124 characters (line_length)

⚠️

Sources/SmileID/Classes/SmileID.swift#L146 - Function should have complexity 10 or less: currently complexity equals 11 (cyclomatic_complexity)

⚠️

Sources/SmileID/Classes/SmileID.swift#L171 - TODOs should be resolved (- Fix when Michael changes thi...). (todo)

⚠️

Sources/SmileID/Classes/Views/JobSubmittable.swift#L27 - TODOs should be resolved (- Fix when Michael changes thi...). (todo)

Generated by 🚫 Danger Swift against 832ecb5

@tobitech tobitech changed the title Add Upload Request Timeout Add Upload Request Timeout, Fix API Error Messages Sep 13, 2024
@@ -3,5 +3,5 @@ import Foundation
protocol RestServiceClient {
func send<T: Decodable>(request: RestRequest) async throws -> T
func multipart<T: Decodable>(request: RestRequest) async throws -> T
func upload(request: RestRequest) async throws -> AsyncThrowingStream<UploadResponse, Error>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe document this as well?

do {
let urlRequest = try request.getUploadRequest()
let configuration = URLSessionConfiguration.default
configuration.timeoutIntervalForRequest = uploadRequestTimeout
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tobitech on android this applies to all requests not just the upload, not sure if I missed the discussion but could there be a reason why we're only usingthe timeout on the upload only?

@tobitech tobitech merged commit 4e8d8da into main Sep 17, 2024
3 checks passed
@tobitech tobitech deleted the upload-request-timeout branch September 17, 2024 08:11
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

Successfully merging this pull request may close these issues.

3 participants