-
Notifications
You must be signed in to change notification settings - Fork 105
1093: Launch Side Effects atomically so they are always started #1102
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
Conversation
38f4e05
to
c1b5d1f
Compare
workflow-runtime/src/commonMain/kotlin/com/squareup/workflow1/internal/WorkflowNode.kt
Outdated
Show resolved
Hide resolved
bb695ea
to
fd02fec
Compare
* - The dispatcher is always set to [Unconfined][kotlinx.coroutines.Dispatchers.Unconfined] to | ||
* minimize overhead for workers that don't care which thread they're executed on (e.g. logging | ||
* side effects, workers that wrap third-party reactive libraries, etc.). If your work cares | ||
* which thread it runs on, use [withContext][kotlinx.coroutines.withContext] or | ||
* [flowOn][kotlinx.coroutines.flow.flowOn] to specify a dispatcher. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just out-dated. Not true for some time (since GUWT and side effects I think), but we hadn't updated documentation.
workflow-runtime/src/commonTest/kotlin/com/squareup/workflow1/RenderWorkflowInTest.kt
Outdated
Show resolved
Hide resolved
workflow-runtime/src/commonMain/kotlin/com/squareup/workflow1/RenderWorkflow.kt
Outdated
Show resolved
Hide resolved
@@ -543,35 +485,6 @@ class RenderWorkflowInTest { | |||
} | |||
} | |||
|
|||
@Test | |||
fun `side_effects_from_initial_rendering_in_non_root_workflow_are_never_started_when_initial_render_of_non_root_workflow_fails`() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we repurpose these tests to confirm that they are run?
fd02fec
to
1b1acda
Compare
Solves #1093 Add headlessIntegrationTest to use for the new test case
1b1acda
to
9f24c0d
Compare
This doesn't work because while the wrapped coroutine will be started, the block declared and passed to UPDATE: that will only happen for nested Workflows - but this is actually a lot of them. I'm going to update the test case to be nested to see if it would fail. |
Add headlessIntegrationTest to renderWorkflowIn with a nice Turbine attached.
Check that we do not use the Unconfined dispatcher within the Workflow runtime as it does not provide ordering guarantees. Coroutines are resumed on whatever thread was last suspended. This means we could start sending actions within a side effect into a unfrozen RenderContext as we cannot guarantee the ordering of handling side effects.
Update documentation and tests to note the need to use a Dispatcher other than Dispatchers.Unconfined.