You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SentryParser counts Error message lines in error.framesToPop #9656
// Access and store the stacktrace property before doing ANYTHING
// else to it because Opera is not very good at providing it
// reliably in other circumstances.
conststacktrace=ex.stacktrace||ex.stack||'';
constpopSize=getPopSize(ex);
try{
returnstackParser(stacktrace,popSize);
}catch(e){
// no-empty
}
return[];
}
// Based on our own mapping pattern - https://github.com/getsentry/sentry/blob/9f08305e09866c8bd6d0c24f5b0aabdd7dd6c59c/src/sentry/lang/javascript/errormapping.py#L83-L108
@timfish The skipFirst is now used to skip the first x lines of the error stack string which is true, but I believe it should not skip the lines of the error stack string but actual parsed frames.
The value passed to the skipFirst is framesToPop, if set to one I would expect the first frame to be skipped but all frames are present because only the message from the stack string is skipped.
We can see that we used tracekit virtually unmodified from when it was forked and I can see that at that point it did parse the frames first and then pop a frame:
I think the current stack line parser regex is stricter than back in 2019 and since we drop lines that could not be parsed, this automatically strips the Invariant Violation: Minified React error line from the frames. This is why the tests continued to pass after many modifications and updates to how stack parsing works. We could (and probably should) strip out all the framesToPop code and the parser tests would all continue to pass.
Do you have an example stack string where the parsing isn't working as expected? We currently have a single test case that hasn't been modified in 4 years and has continued to pass.
Activity
AbhiPrasad commentedon Nov 27, 2023
Oh shoot - good catch cc @timfish
timfish commentedon Nov 30, 2023
I'm just trying to understand what's not working as expected here.
skipFirstis specifically used to skip the error message.The logic to handle
framesToPopis here:sentry-javascript/packages/browser/src/eventbuilder.ts
Lines 91 to 127 in 59db749
We've got a couple of tests that use
framesToPop, are these wrong or incomplete?sentry-javascript/packages/browser/test/unit/tracekit/react.test.ts
Lines 4 to 8 in 59db749
krystofwoldrich commentedon Jan 10, 2024
@timfish The
skipFirstis now used to skip the first x lines of the error stack string which is true, but I believe it should not skip the lines of the error stack string but actual parsed frames.The value passed to the
skipFirstisframesToPop, if set to one I would expect the first frame to be skipped but all frames are present because only the message from the stack string is skipped.sentry-javascript/packages/browser/test/unit/tracekit/react.test.ts
Lines 4 to 8 in 59db749
The tests I believe are wrong as they expect no frames to be skipped when
framesToPopis set to1.Skipping the lines of the string is unpredictable as the message can have multiple lines.
timfish commentedon Jan 11, 2024
@krystofwoldrich many thanks for the detailed explanation and bearing with me 🙂
timfish commentedon Jan 11, 2024
It looks like the
framesToPopproperty on the error doesn't make a difference with the current parser.If we look waaaay back when this test was added:
2979b2c
And browser the source at that point:
https://github.com/getsentry/sentry-javascript/tree/2979b2c5b09a80980a8765272dde246564c82dfd
We can see that we used tracekit virtually unmodified from when it was forked and I can see that at that point it did parse the frames first and then pop a frame:
sentry-javascript/packages/browser/src/tracekit.ts
Lines 880 to 883 in 2979b2c
But even back then, 4 frames were expected in the test case:
sentry-javascript/packages/browser/test/unit/tracekit/custom.test.ts
Lines 305 to 336 in 2979b2c
I think the current stack line parser regex is stricter than back in 2019 and since we drop lines that could not be parsed, this automatically strips the
Invariant Violation: Minified React errorline from the frames. This is why the tests continued to pass after many modifications and updates to how stack parsing works. We could (and probably should) strip out all theframesToPopcode and the parser tests would all continue to pass.Do you have an example stack string where the parsing isn't working as expected? We currently have a single test case that hasn't been modified in 4 years and has continued to pass.
krystofwoldrich commentedon Feb 8, 2024
@timfish I've opened a PR as it might be easier to resolve this than talking theory.
I believe there were two things mixed from the beginning.
Skipping a line of the stack string which otherwise would be parsed as a valid frame although it's not a frame.
Minified React error #31; visit https://reactjs.org/docs/error-decoder.html?invariant=31&args[]=object%20with%20keys%20%7B%7D&args[]= forSkipping the actual frame, React uses
invariant.jswhich setsframesToPop=1to remove the invariant frame as this will be the same in all the errors.