Skip to content

Conversation

dhavalshreyas
Copy link
Contributor

Queued Events

Queued Events are events sent to the Sink synchronously while Screens are being updated. We queue them up and are applied after the Screen update operation.

Issues

Our existing implementation of Queued events handling has a few issues:

  • Each Workflow node can handle only one event, if another event is sent, we fatalError with a Action sent to pipe while in the pending state. message.
  • If multiple Workflow nodes have events queued, only one of them will be handled, the rest are silently dropped.
  • Due to a bug in enabling and handling EventPipes while handling queued events, the Workflow tree can get into an inconsistent state and sometimes leads to a crash.

Solution

To solve this issue, in this PR, we are not queueing events in the SubtreeManager, instead we schedule the event to be delivered to the EventPipe asynchronously. This fixes the issues outlined above.


case .queued:
fatalError("[\(WorkflowType.self)] Action sent to pipe while already in the `queueing` state.")
fatalError("[\(WorkflowType.self)] Action sent to pipe while in the `pending` state.")
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought this PR was to eliminate this error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this should not be possible, however the .pending state will continue to exist. fatal ensures we don't hit this spot.

@rjrjr rjrjr self-requested a review February 24, 2021 20:14
Copy link
Collaborator

@AquaGeek AquaGeek left a comment

Choose a reason for hiding this comment

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

Have we run this against the tests in the monorepo?

@dhavalshreyas
Copy link
Contributor Author

Have we run this against the tests in the monorepo?

Yes, all green.

@dhavalshreyas dhavalshreyas merged commit 1bb88ca into main Feb 24, 2021
@dhavalshreyas dhavalshreyas deleted the dhaval/sinkQueuedEvents branch February 24, 2021 22: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.

3 participants