Skip to content

Commit

Permalink
fix(Logging): configure logging after auth to fix a race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh62 committed Oct 18, 2024
1 parent 619867b commit 894619f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
5 changes: 1 addition & 4 deletions Amplify/Core/Configuration/AmplifyConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,9 @@ extension Amplify {
}
}

// Always configure logging first since Auth dependings on logging
try configure(CategoryType.logging.category, using: resolvedConfiguration)

// Always configure Hub and Auth next, so they are available to other categories.
// Auth is a special case for other plugins which depend on using Auth when being configured themselves.
let manuallyConfiguredCategories = [CategoryType.hub, .auth]
let manuallyConfiguredCategories = [CategoryType.hub, .auth, .logging]
for categoryType in manuallyConfiguredCategories {
try configure(categoryType.category, using: resolvedConfiguration)
}
Expand Down
5 changes: 1 addition & 4 deletions Amplify/Core/Configuration/AmplifyOutputsData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,9 @@ extension Amplify {
/// - Tag: Amplify.configure
@_spi(InternalAmplifyConfiguration)
public static func configure(_ configuration: AmplifyOutputsData) throws {
// Always configure logging first since Auth dependings on logging
try configure(CategoryType.logging.category, using: configuration)

// Always configure Hub and Auth next, so they are available to other categories.
// Auth is a special case for other plugins which depend on using Auth when being configured themselves.
let manuallyConfiguredCategories = [CategoryType.hub, .auth]
let manuallyConfiguredCategories = [CategoryType.hub, .auth, .logging]
for categoryType in manuallyConfiguredCategories {
try configure(categoryType.category, using: configuration)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ public class AWSCloudWatchLoggingPlugin: LoggingCategoryPlugin {
localStore.reset()
}

DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500)) {
self.loggingClient.takeUserIdentifierFromCurrentUser()
}
self.loggingClient.takeUserIdentifierFromCurrentUser()
}
}

Expand Down

0 comments on commit 894619f

Please sign in to comment.