Open yannbf opened 2 years ago
I think this will generate an interesting discussion about running phases. @ghengeveld @tmeasday
@yannbf and I discussed this already and I think we have an important decision to make here.
So far we've said that if a story re-renders without remounting (i.e. args/globals changes), we basically "ignore" the play function. So:
3&4 are probably similar with respect to this problem, although 4 is far more likely and easier to reproduce. The issue is that user code could easily retain references to elements that are no longer around after the args have changed. Then the play function is going to throw weird errors when it is restarted.
I think there is a strong argument in favour of "correctness" here that says we should abort the play function if running/paused when you re-render. The user can always hit the "replay" function if they want to run it again from scratch.
[1] This one seems fine, there's probably nothing else we can do that makes sense.
@tmeasday I agree that we should side with correctness in all testing/debugging things.
Discussed this with @tmeasday, we came up with the following approach:
next
(FORCE_REMOUNT
with isDebugging: true
)FORCE_REMOUNT
event)@tmeasday will deal with HMR. I'll deal with args/globals changes. Parts 2 and 4 we'll handle when we deal with other debugger issues for 6.4 stabilization.
Discussed this with @tmeasday, we came up with the following approach:
- On args/globals change (i.e. rerender) while playing: continue playing (don't rerun play function). In case this blows up, show the error on the Interactions tab rather than in a redbox.
- On args/globals change (i.e. rerender) while debugging: remount and play to step on
next
(FORCE_REMOUNT
withisDebugging: true
)- On HMR while playing: remount and rerun play from start (
FORCE_REMOUNT
event)- On HMR while debugging: remount and play to step
@tmeasday will deal with HMR. I'll deal with args/globals changes. Parts 2 and 4 we'll handle when we deal with other debugger issues for 6.4 stabilization.
Sounds logical and perfect! 🚀
I'm also 💯 onboard with this approach!
In case 1 (args change during play fn) we should probably focus the interactions tab to make sure people know what went wrong when there's an error
@ghengeveld just to be clear I can confirm that the full rendering stack reruns when HMR occurs -- c.f. these tests:
Yippee!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.4.0-beta.27 containing PR #16574 that references this issue. Upgrade today to the @next
NPM tag to try it out!
npx sb upgrade --prerelease
Closing this issue. Please re-open if you think there's still more to do.
@ghengeveld should we re-open this, given the changes so far only affect scenarios 1&2 above? Or create a new 6.5 ticket for the remaining two?
@tmeasday I created a ticket in Linear for it. CH-900
@ghengeveld can you update us regarding this? Linear changed and I couldn't find that ticket anymore.
Reopening so we don't lose track of the required HMR behavior change (3+4 above). Here's the Linear ticket
Describe the bug
If you are stepping through a story's interaction in the panel, and while you're pause you interact with controls or globals (such as a toolbar item), the story will fail in the next interaction.
Here's a commented video to show the steps:
https://user-images.githubusercontent.com/1671563/138229662-b27a1d18-6f5b-466d-9515-9e4d0769720d.mov
To Reproduce
Go back
Go forward
┆Issue is synchronized with this Asana task by Unito