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

fix: Prevent crash when the SDK has not been initialized #95

Merged
merged 1 commit into from
May 1, 2023

Conversation

cbaker6
Copy link
Member

@cbaker6 cbaker6 commented May 1, 2023

New Pull Request Checklist

Issue Description

The SDK can crash if the developer makes a call that requires a ParseSwift config parameter, but hasn't properly configured the SDK.

Approach

Suspend all method calls that access the SDK config parameters until the SDK is initialized or throw an error after the default time limit (current 5 seconds) if the suspend time is exceeded.

TODOs before merging

  • Add tests
  • Add entry to changelog

@codecov
Copy link

codecov bot commented May 1, 2023

Codecov Report

Merging #95 (e331378) into main (1c4d8c3) will increase coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #95      +/-   ##
==========================================
+ Coverage   91.42%   91.46%   +0.03%     
==========================================
  Files         172      172              
  Lines       15261    15295      +34     
==========================================
+ Hits        13953    13990      +37     
+ Misses       1308     1305       -3     
Impacted Files Coverage Δ
Sources/ParseSwift/API/API+Command.swift 88.08% <100.00%> (ø)
...urces/ParseSwift/API/API+NonParseBodyCommand.swift 80.00% <100.00%> (+0.12%) ⬆️
...s/ParseSwift/Objects/ParseInstallation+async.swift 93.26% <100.00%> (ø)
Sources/ParseSwift/Objects/ParseInstallation.swift 91.80% <100.00%> (+0.03%) ⬆️
Sources/ParseSwift/Objects/ParseObject+async.swift 95.86% <100.00%> (ø)
Sources/ParseSwift/Objects/ParseObject.swift 90.95% <100.00%> (-0.24%) ⬇️
Sources/ParseSwift/Objects/ParseUser+async.swift 94.84% <100.00%> (ø)
Sources/ParseSwift/Objects/ParseUser.swift 93.48% <100.00%> (+0.01%) ⬆️
Sources/ParseSwift/Protocols/Objectable.swift 97.95% <100.00%> (+0.45%) ⬆️
Sources/ParseSwift/Types/ParseFile.swift 94.64% <100.00%> (+0.02%) ⬆️
... and 1 more

... and 1 file with indirect coverage changes

@@ -88,11 +90,22 @@
}
}

/// Specifies if a `ParseObject` has been saved.
public func isSaved() async throws -> Bool {

Check warning

Code scanning / Tailor (reported by Codacy)

Function should have at least one blank line after it

Function should have at least one blank line after it
func toPointer() throws -> PointerType {
return try PointerType(self)
}

func endpoint(_ method: API.Method) -> API.Endpoint {
func endpoint(_ method: API.Method) async throws -> API.Endpoint {

Check warning

Code scanning / Tailor (reported by Codacy)

Function should have at least one blank line after it

Function should have at least one blank line after it
@cbaker6 cbaker6 merged commit a746db0 into main May 1, 2023
@cbaker6 cbaker6 deleted the pauseConfig branch May 1, 2023 16:13
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.

Getting "Swift runtime failure: Unexpectedly found nil while implicitly unwrapping an Optional value" error
1 participant