Stackflow transition breaks when activity suspends longer than transitionDuration
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1k
- Forks
- 114
- Avg merge
- 3m
- Merged PRs (30d)
- 2
Description
Currently, Stackflow activities' enter transition is only expressed with enter-active and enter-done. However, this doesn't work well with frameworks that do concurrent rendering because the core state update happens regardless of whether activities render synchronously or suspend during render. This results in something like this:
sequenceDiagram
participant Core as @stackflow/core
participant Integration as Integration (@stackflow/react)
participant View
View->>Core: push()
activate Core
note left of Core: Transition
Core->>Integration: notify on subscribe() listener
Integration->>Core: getStack()
Core->>Integration: State with `enter-active`
Integration->>View: Render new activity with `enter-active`
activate View
note right of View: Suspend
Core->>Integration: notify on subscribe() listener
deactivate Core
Integration->>Core: getStack()
Core->>Integration: State with `enter-done`
Integration->>View: Rerender with `enter-done`
deactivate View
note right of View: Initial render with `enter-done`
As described above, if the view suspends longer than the core transition, the initial render of the view is done with enter-done state, resulting in broken CSS transitions.
To mitigate this, the core transition should be started after confirming that the initial view was rendered. These are the required parts to implement the feature:
- Add a new transition state to express activities that didn't complete the initial render. (
enter-pending?) - Add a new action that notifies the core after completing the initial render. (no idea about naming 🥲)
I'm willing to implement the feature after the direction is fixed.
Related: #434
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the transition state and subscription flow between @stackflow/core and @stackflow/react, using the sequence in this issue and related issue #434 as context. Define how the pending state and post-render action should interact with suspended activities. Done means the initial render cannot skip the enter transition when suspension outlasts transitionDuration, with the behavior covered by the relevant existing tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100