-
Notifications
You must be signed in to change notification settings - Fork 138
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
Skip redux middleware frames on jumping to location #9485
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
src/ui/utils/redux.ts
Outdated
} catch (e) { | ||
return false; | ||
} | ||
} |
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.
it'd be nice to write some jest unit tests for this function
devtools/src/ui/utils/time.test.ts
Line 4 in 7731de4
describe("formatDuration", () => { |
devtools/src/ui/utils/app.test.ts
Line 4 in 7731de4
describe("getNonLoadingRegionTimesFromLoadingRegions", () => { |
step.location.sourceId === preferredLocation.sourceId && | ||
step.location.line === preferredLocation.line | ||
); | ||
}); |
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.
Now that this function is getting more complex, it might be nice to pull this logic for getting the matching frame step into a util
function getMatchingFrameStep(frameSteps, preferredLocation) {
...
}
btw i'm not sure if this is the best API.
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.
FWIW the real answer here is to implement https://linear.app/replay/issue/BAC-2915/stack-frames-should-come-with-execution-points and stop trying to calculate this ourselves.
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.
I've moved it into a separate util for now since ReactPanel.tsx
and ReduxDevtools.tsx
are doing the same thing but yes having frames have their execution point would make it alot simpler
This should now be able to give more accurate results. It can identify code like Need to add code for handling cases where the callback gets declared first, and is later returned |
Not sure this is working as intended atm. If I look at https://devtools-git-fork-mokshit06-redux-skip-middleware-recordreplay.vercel.app/recording/breakpoints-01-test-basic-breakpoint-functionality--326d54a3-1523-411a-95ca-018537f5a887 , the jump locations are all still landing inside of the |
Oh I know why this example isn't working. Babel isn't able to parse the typescript code. Will need to include typescript plugin for ts/tsx files. Try running it on JS examples like https://devtools-dk0k2y9tu-recordreplay.vercel.app/recording/e2etestscenariosjoinsreproductions22859-multi-nested-joins-wrong-aliasingcyspecjs--77ed307a-f284-4d5d-b0e0-b5176d252326 |
@Mokshit06 I just realized there might be a simpler approach here. All Redux middleware are going to be going through Can we do something to find the |
Oh that's a good point. How often does the name/path of this file change? Maybe that could be a good way to identify if it's the correct step. Another option could be to go through all the frame steps and based on the |
The filename shouldn't change, but there are some funky edge cases I've found where there can be more than one copy of Was working on some of that logic over in #9410 for the perf analysis POC. Want to try grabbing some of that "find the right Redux file" code from there and use it here to identify the right method here? I think you can actually borrow a bunch of the logic that was already trying to find "the right |
@@ -79,6 +86,41 @@ export const ReduxDevToolsPanel = () => { | |||
); | |||
}; | |||
|
|||
async function isInsideApplyMiddlwareFn( |
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.
✋ It'll be smoother if we do the applyMiddleware
function lookup once, then have a separate function that does the "is frame in function declaration" comparison synchronously
src/ui/utils/frame.ts
Outdated
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.
Not sure this is a good place for this code to go, but I also don't have a better suggestion atm :)
Looks reasonable at this point - can you fix up the merge conflict? |
779df8c
to
ac00bb7
Compare
Hmm. I just tried it on a Metabase recording, and ended up exactly inside of the original I definitely see the Can you do some more looking into this? |
dispatch(seek(jumpLocation.point, jumpLocation.time, true)); | ||
dispatch(seek(point, time, true)); |
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.
Ah so while resolving the conflict I see this got changed to the initial point and time rather than the calculated ones.
I'm out right now but will fix this.
@Mokshit06 looks like this needs a rebase |
I tried this on a recording of the Redux starter template and a call to |
Per discussion in Discord, Mokshit is going to try looking at figuring out "are we in a middleware" by looking just at source outline data to determine if this is a triply-nested function. |
@markerikson This seems to be working now. It tries to search the call stack initially for |
Hah, I hate to keep asking you to make more tweaks, but I see one more filename we should exclude: |
Okay, looks good! Just need to fix the merge conflicts and I think this is ready! |
1aacd78
to
d609cd2
Compare
Huh, looks like this is missing a |
Hm that's weird, I don't see anything in this PR that would change the env variables |
Superseded by #9573 . |
Experimenting with using babel to figure out which pause frames are of redux middlewares instead of
dispatch
.It finds the identifier at the column and line where the first user frame paused and matches if the parent functions have the pattern
store => next => action => {}
using babel traversal. If so then skips that frame and moves to the next one.This is a very basic test, and needs to check for more cases, like checking at each step that the parent function is returned the child one. eg. in
next => action => {}
,action => {}
is the child function. It's parent function isnext => {}
, andnext
is returnedaction
.