Skip to content

Conversation

@jamieQ
Copy link
Contributor

@jamieQ jamieQ commented Aug 9, 2023

Issue

the issue manifests in the following scenario:

  1. an action is sent to node A
  2. the subsequent re-render caused by handling the action removes node A from the tree, invalidating its EventPipe in the process
  3. an observer of the WorkflowHost's rendering signal synchronously sends another event that propagates to node A when the rendering signal updates
  4. action handling of this second event hits a fatal assertion because A’s event pipe has been marked as ‘invalid’

Changes

  • removes the fatal assertion in favor of dropping the events and emitting debug console logging/regular assertions when this occurs
  • adds a reentrancy check to differentiate when a sink is being used multiple times in the same call stack, likely due to UIKit doing synchronous things when Renderings are being updated but before action handling has fully unwound from the stack
  • adds a regular assertion failure in the case an invalidated Sink is messaged when not in the re-entrant scenario
  • updates tests

i asked around, and it seems that the Kotlin runtime has not enforced this hard assertion for some time, and i could not think of a compelling reason to continue doing it.

Checklist

  • Unit Tests
  • UI Tests (n/a)
  • Snapshot Tests (iOS only) (n/a)
  • I have made corresponding changes to the documentation (n/a)

@jamieQ jamieQ marked this pull request as ready for review August 9, 2023 22:31
@jamieQ jamieQ requested a review from a team as a code owner August 9, 2023 22:31
Copy link
Contributor

@square-tomb square-tomb left a comment

Choose a reason for hiding this comment

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

Nice test!

handler(event)

case .invalid:
fatalError("[\(WorkflowType.self)] Sink sent an action after it was invalidated. Sinks can only be used for a single valid `Rendering`.")

Choose a reason for hiding this comment

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

This should be pretty uncommon, right? Would it make sense to at least log to BugSnag if this happens in production?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes i believe it's fairly uncommon, at least according to our existing bugsnag data. we don't actually currently have a straightforward mechanism to log errors/warnings to something listening from outside of this module, so that can be taken up as a follow-on task.

@jamieQ jamieQ force-pushed the jquadri/relax-invalid-eventpipe-invariant branch from ef9634c to fdaa827 Compare August 14, 2023 20:55
@jamieQ jamieQ force-pushed the jquadri/relax-invalid-eventpipe-invariant branch from f95166d to af3e543 Compare August 15, 2023 17:47
@jamieQ jamieQ merged commit d5f33e4 into main Aug 15, 2023
@jamieQ jamieQ deleted the jquadri/relax-invalid-eventpipe-invariant branch August 15, 2023 18:30
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.

5 participants