swift-composable-architecture: 2FA SwiftUI crashes in TicTacToe example

Describe the bug In the TicTacToe example application, when you choose the SwiftUI application flow and opt into the Two Factor Auth. section, when you tap “Next” after typing in 1234, the app with crash with the error:

Fatal error: "LoginAction.twoFactorDismissed" was received by an optional reducer when its state was "nil". This can happen for a few reasons:

with a long list of reasons as to why it’s potentially crashed.

This crash appears to be caused by LoginSwiftView.swift line num. 71. where the app sends .twoFactorDismissed to the now nil’d out LoginState, as the NavigationLink receives false for the isActive binding.

To Reproduce

  • Open the TicTacToe sample application
  • Select SwiftUI version
  • Enter 2fa@test.com in the Email field
  • Enter password in the Password field
  • Tap Log in
  • Enter 1234 and tap Submit
  • App navigates to the New Game screen, then immediately crashes

Expected behavior I expected the app to progress to the New Game screen and not crash 😅

Screenshots Screenshot 2021-02-24 at 09 25 43

Environment

  • Xcode 12.4
  • Swift 5.3
  • Composable Architecture version 0.15.0

Additional context If you login with the 2FA flow through the UIKit version, it doesn’t crash, and retains the login if you navigate backwards and switch to the SwiftUI version.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Ahhh, yes, we plan on discussing that very soon.

@ericlewis care sharing the workaround? I’m being blocked by this very issue.

EDIT: looks like the 0.16.0 release contains a “fix” where the assertionFailure is replaced by a breakpoint in DEBUG builds.