xstate-viz icon indicating copy to clipboard operation
xstate-viz copied to clipboard

Fixed an issue with machines created by `withConfig`/`withContext` not being captured

Open Andarist opened this issue 4 years ago • 6 comments
trafficstars

fixes https://github.com/statelyai/xstate-viz/issues/300

but... the console output after the fix is:

in-config log
withConfig log
in-config log

that is because we capture 2 machines here (and this is somewhat an expected result as per https://github.com/statelyai/xstate-viz/pull/214, just not really in this case). This shows the limits of the current eval-like approach. It's basically impossible to cover common scenarios correctly without static analysis, cc @davidkpiano

Andarist avatar Oct 19 '21 17:10 Andarist

⚠️ No Changeset found

Latest commit: d3301379fd95b1af11c939946a691bc9ff26699d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Oct 19 '21 17:10 changeset-bot[bot]

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/statelyai/xstate-viz/Bf758rUEPCyTEf5KPZKn9exfctKF
✅ Preview: https://xstate-viz-git-andarist-fix-300-statelyai.vercel.app

vercel[bot] avatar Oct 19 '21 17:10 vercel[bot]

This shows the limits of the current eval-like approach. It's basically impossible to cover common scenarios correctly without static analysis

The other solution here is to opt into reading from inspect(someMachine).start(), then interpreted machines can be visualized the same as how inspected machines are.

davidkpiano avatar Oct 19 '21 19:10 davidkpiano

The other solution here is to opt into reading from inspect(someMachine).start(), then interpreted machines can be visualized the same as how inspected machines are.

Yes, we could differentiate the behavior based on the interpret calls being in the source file but that's kinda a hidden feature, people wouldn't easily realize the difference on their own.

Either way - this probably ain't a discussion for now. While this is gonna be slightly surprising - it's better than not supporting withConfig at all, right? 🤔 cc @mattpocock

Andarist avatar Oct 20 '21 08:10 Andarist

The other solution here is to opt into reading from inspect(someMachine).start(), then interpreted machines can be visualized the same as how inspected machines are.

Yes, we could differentiate the behavior based on the interpret calls being in the source file but that's kinda a hidden feature, people wouldn't easily realize the difference on their own.

Either way - this probably ain't a discussion for now. While this is gonna be slightly surprising - it's better than not supporting withConfig at all, right? 🤔 cc @mattpocock

Yep, this solution works for now

davidkpiano avatar Oct 20 '21 10:10 davidkpiano

@Andarist could we compare the config objects we receive and deduplicate them? That would prevent the doubling of logs.

mattpocock avatar Oct 20 '21 13:10 mattpocock