sentry-react-native icon indicating copy to clipboard operation
sentry-react-native copied to clipboard

Fix: don't symbolicate console asserts that comes from metro.

Open lucas-zimerman opened this issue 10 months ago • 10 comments

:loudspeaker: Type of change

  • [x] Bugfix
  • [ ] New feature
  • [ ] Enhancement
  • [ ] Refactoring

:scroll: Description

Adds a small patch to DebugSymbolicator that ignores events generated by metro.

:bulb: Motivation and Context

In short: when interacting with the metro bridge, React Native uses the following code: https://gitlab.cin.ufpe.br/vrs2/iot-trafficlight-final/-/blob/main/node_modules/event-target-shim/dist/event-target-shim.mjs?ref_type=heads#L40

/**
 * Get private data.
 * @param {Event} event The event object to get private data.
 * @returns {PrivateData} The private data of the event.
 * @private
 */
function pd(event) {
    const retv = privateData.get(event);
    console.assert(
        retv != null,
        "'this' is expected an Event object, but got",
        event
    );
    return retv
}

When adding the Sentry console integration and also filtering by asserts, the above snippet can be called when we are symbolicating in dev builds, creating new events, that would then, be again symbolicated, and so on... By avoiding the symbolication of events that comes from this specific assert, apps when tested in debug mode should no longer freeze when loading the console integration.

Fixes: https://github.com/getsentry/sentry-react-native/issues/3992

Lastly. I marked it as no breaking changes since this only affect local builds

:green_heart: How did you test it?

Tests, locally, replicated the problematic library code so it is easier to test it on the sample app.

:pencil: Checklist

  • [x] I added tests to verify changes
  • [x] No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled
  • [ ] I updated the docs if needed.
  • [ ] I updated the wizard if needed.
  • [ ] All tests passing
  • [x] No breaking changes

:crystal_ball: Next steps

lucas-zimerman avatar Apr 22 '25 21:04 lucas-zimerman

Android (legacy) Performance metrics :rocket:

  Plain With Sentry Diff
Startup time 395.92 ms 405.82 ms 9.90 ms
Size 17.75 MiB 20.13 MiB 2.38 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
80b2ce3d0ebe86bf1196944a2036912f6670295c 385.02 ms 387.36 ms 2.34 ms
8bda0cc4900623be81707f69ca2d0d3f36a8b9ff 450.38 ms 433.89 ms -16.49 ms
457e29fc08e6edbebee646d095513d72728a5756 398.10 ms 421.39 ms 23.29 ms
7d161c03aa7f2b984b4de956c87899aba0c187a5 413.02 ms 435.29 ms 22.26 ms
ddc055269a330116a386e595d3952b88af6cd24a 472.92 ms 460.66 ms -12.26 ms
07e58c9e1566d445d660d68ccbc08a4b8755d18e 495.04 ms 489.73 ms -5.31 ms
950b04f12dfc4a726b064dc439166f71d808da8f 433.92 ms 462.43 ms 28.51 ms
3f05680301917556cc58f173d8a674cb5af6682c 397.91 ms 405.65 ms 7.74 ms
e73d82f5e34d416eca0eb58c76599fb625345e48 475.82 ms 506.55 ms 30.73 ms
2de79dc03ad46c8953cc59235f95b01dd2677bba 435.31 ms 416.96 ms -18.35 ms

App size

Revision Plain With Sentry Diff
80b2ce3d0ebe86bf1196944a2036912f6670295c 17.73 MiB 19.75 MiB 2.02 MiB
8bda0cc4900623be81707f69ca2d0d3f36a8b9ff 17.75 MiB 20.11 MiB 2.36 MiB
457e29fc08e6edbebee646d095513d72728a5756 17.73 MiB 19.84 MiB 2.10 MiB
7d161c03aa7f2b984b4de956c87899aba0c187a5 17.75 MiB 20.12 MiB 2.37 MiB
ddc055269a330116a386e595d3952b88af6cd24a 17.74 MiB 20.09 MiB 2.35 MiB
07e58c9e1566d445d660d68ccbc08a4b8755d18e 17.74 MiB 20.08 MiB 2.34 MiB
950b04f12dfc4a726b064dc439166f71d808da8f 17.75 MiB 20.13 MiB 2.38 MiB
3f05680301917556cc58f173d8a674cb5af6682c 17.75 MiB 20.11 MiB 2.37 MiB
e73d82f5e34d416eca0eb58c76599fb625345e48 17.73 MiB 20.07 MiB 2.33 MiB
2de79dc03ad46c8953cc59235f95b01dd2677bba 17.75 MiB 20.13 MiB 2.38 MiB

Previous results on branch: lz/fix-console

Startup times

Revision Plain With Sentry Diff
4fd28ccd81a64f39285f954e5ed682ee1770588c 428.30 ms 443.88 ms 15.58 ms
63aead81524449e94bc6c43487a75bd8de99b587 427.73 ms 422.74 ms -4.98 ms

App size

Revision Plain With Sentry Diff
4fd28ccd81a64f39285f954e5ed682ee1770588c 17.75 MiB 20.13 MiB 2.38 MiB
63aead81524449e94bc6c43487a75bd8de99b587 17.75 MiB 20.13 MiB 2.38 MiB

github-actions[bot] avatar Apr 22 '25 21:04 github-actions[bot]

iOS (legacy) Performance metrics :rocket:

  Plain With Sentry Diff
Startup time 1219.22 ms 1219.24 ms 0.02 ms
Size 2.63 MiB 3.79 MiB 1.16 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
484813b771d99e76c96e5cdea202fdc767bd7cf9+dirty 1222.45 ms 1220.79 ms -1.66 ms
b6da94a00f2df286e3aef66616882595bf45dc04+dirty 1227.82 ms 1238.86 ms 11.04 ms
60d7316ea11aceb94c97c4d1b926f271964e0407+dirty 1219.13 ms 1221.74 ms 2.61 ms
9f0f6c83fbb234e0b6a3dd2897429782821da87f+dirty 1231.60 ms 1232.73 ms 1.12 ms
4a6664fa7140687cfa079f2d738b59b18e4ac7b7+dirty 1209.49 ms 1208.63 ms -0.86 ms
b7e707eba7c3977018d4871ede3ea2b6f7e4a3d4+dirty 1220.48 ms 1229.53 ms 9.05 ms
f80e57eb7a15d1b57496089e3eca10b9a4349b3c+dirty 1217.29 ms 1230.61 ms 13.32 ms
0db0c729a4ac7c205a44cb4702fa7ba5b0bc03c0+dirty 1275.02 ms 1285.84 ms 10.82 ms
c639edf12520d1afee79e1ff2ba18df03ce70ec3+dirty 1236.18 ms 1235.04 ms -1.14 ms
a15d3705c6400e7254598c11e8db8a705807eace+dirty 1214.69 ms 1214.02 ms -0.67 ms

App size

Revision Plain With Sentry Diff
484813b771d99e76c96e5cdea202fdc767bd7cf9+dirty 2.36 MiB 3.08 MiB 734.18 KiB
b6da94a00f2df286e3aef66616882595bf45dc04+dirty 2.63 MiB 3.76 MiB 1.13 MiB
60d7316ea11aceb94c97c4d1b926f271964e0407+dirty 2.63 MiB 3.74 MiB 1.11 MiB
9f0f6c83fbb234e0b6a3dd2897429782821da87f+dirty 2.36 MiB 3.10 MiB 759.48 KiB
4a6664fa7140687cfa079f2d738b59b18e4ac7b7+dirty 2.36 MiB 3.04 MiB 696.39 KiB
b7e707eba7c3977018d4871ede3ea2b6f7e4a3d4+dirty 2.63 MiB 3.76 MiB 1.13 MiB
f80e57eb7a15d1b57496089e3eca10b9a4349b3c+dirty 2.63 MiB 3.78 MiB 1.14 MiB
0db0c729a4ac7c205a44cb4702fa7ba5b0bc03c0+dirty 2.36 MiB 2.84 MiB 487.01 KiB
c639edf12520d1afee79e1ff2ba18df03ce70ec3+dirty 2.36 MiB 3.08 MiB 736.63 KiB
a15d3705c6400e7254598c11e8db8a705807eace+dirty 2.63 MiB 3.76 MiB 1.13 MiB

Previous results on branch: lz/fix-console

Startup times

Revision Plain With Sentry Diff
4fd28ccd81a64f39285f954e5ed682ee1770588c+dirty 1214.26 ms 1226.96 ms 12.70 ms
63aead81524449e94bc6c43487a75bd8de99b587+dirty 1207.92 ms 1219.14 ms 11.23 ms

App size

Revision Plain With Sentry Diff
4fd28ccd81a64f39285f954e5ed682ee1770588c+dirty 2.63 MiB 3.78 MiB 1.14 MiB
63aead81524449e94bc6c43487a75bd8de99b587+dirty 2.63 MiB 3.78 MiB 1.14 MiB

github-actions[bot] avatar Apr 22 '25 22:04 github-actions[bot]

Android (new) Performance metrics :rocket:

  Plain With Sentry Diff
Startup time 391.38 ms 401.92 ms 10.54 ms
Size 7.15 MiB 8.40 MiB 1.25 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
24cb2a493ad397b81aeab1689de7ab3eca9e2a00+dirty 366.28 ms 410.96 ms 44.68 ms
6e8584e8f1988b33cc24c85f32711c91358905fa+dirty 383.37 ms 400.84 ms 17.47 ms
8bda0cc4900623be81707f69ca2d0d3f36a8b9ff+dirty 383.08 ms 417.40 ms 34.32 ms
13b68d9e631403d83ea00f3e31eb00c0d8e17fdf+dirty 372.54 ms 388.85 ms 16.31 ms
950b04f12dfc4a726b064dc439166f71d808da8f+dirty 308.66 ms 312.69 ms 4.03 ms
1d75738d88ed2afcdaccd497db55ee4126363103+dirty 380.29 ms 376.78 ms -3.52 ms
e2b64fed057d4b01cf7ad79eb19eb3c8b8002a82+dirty 258.82 ms 304.26 ms 45.44 ms
96725779e1dd0e31ecbcc0e9f721577fdb112ff6+dirty 391.55 ms 412.57 ms 21.02 ms
80b2ce3d0ebe86bf1196944a2036912f6670295c+dirty 271.29 ms 316.47 ms 45.18 ms
3ffcddd6248046202afca78f6b9af8e3f591202c+dirty 244.82 ms 295.47 ms 50.65 ms

App size

Revision Plain With Sentry Diff
24cb2a493ad397b81aeab1689de7ab3eca9e2a00+dirty 7.15 MiB 8.38 MiB 1.23 MiB
6e8584e8f1988b33cc24c85f32711c91358905fa+dirty 7.15 MiB 8.13 MiB 1002.18 KiB
8bda0cc4900623be81707f69ca2d0d3f36a8b9ff+dirty 7.15 MiB 8.38 MiB 1.23 MiB
13b68d9e631403d83ea00f3e31eb00c0d8e17fdf+dirty 7.15 MiB 8.38 MiB 1.23 MiB
950b04f12dfc4a726b064dc439166f71d808da8f+dirty 7.15 MiB 8.40 MiB 1.25 MiB
1d75738d88ed2afcdaccd497db55ee4126363103+dirty 7.15 MiB 8.40 MiB 1.25 MiB
e2b64fed057d4b01cf7ad79eb19eb3c8b8002a82+dirty 7.15 MiB 8.07 MiB 947.16 KiB
96725779e1dd0e31ecbcc0e9f721577fdb112ff6+dirty 7.15 MiB 8.38 MiB 1.23 MiB
80b2ce3d0ebe86bf1196944a2036912f6670295c+dirty 7.15 MiB 8.04 MiB 911.02 KiB
3ffcddd6248046202afca78f6b9af8e3f591202c+dirty 7.15 MiB 8.04 MiB 912.17 KiB

Previous results on branch: lz/fix-console

Startup times

Revision Plain With Sentry Diff
4fd28ccd81a64f39285f954e5ed682ee1770588c+dirty 382.06 ms 403.94 ms 21.88 ms
63aead81524449e94bc6c43487a75bd8de99b587+dirty 391.72 ms 411.84 ms 20.12 ms

App size

Revision Plain With Sentry Diff
4fd28ccd81a64f39285f954e5ed682ee1770588c+dirty 7.15 MiB 8.40 MiB 1.25 MiB
63aead81524449e94bc6c43487a75bd8de99b587+dirty 7.15 MiB 8.40 MiB 1.25 MiB

github-actions[bot] avatar Apr 22 '25 22:04 github-actions[bot]

iOS (new) Performance metrics :rocket:

  Plain With Sentry Diff
Startup time 1233.94 ms 1231.29 ms -2.65 ms
Size 3.19 MiB 4.36 MiB 1.17 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
484813b771d99e76c96e5cdea202fdc767bd7cf9+dirty 1225.07 ms 1221.00 ms -4.07 ms
b6da94a00f2df286e3aef66616882595bf45dc04+dirty 1219.33 ms 1223.35 ms 4.02 ms
60d7316ea11aceb94c97c4d1b926f271964e0407+dirty 1224.33 ms 1231.29 ms 6.96 ms
9f0f6c83fbb234e0b6a3dd2897429782821da87f+dirty 1236.94 ms 1245.41 ms 8.47 ms
4a6664fa7140687cfa079f2d738b59b18e4ac7b7+dirty 1218.77 ms 1221.07 ms 2.30 ms
b7e707eba7c3977018d4871ede3ea2b6f7e4a3d4+dirty 1220.86 ms 1225.53 ms 4.67 ms
f80e57eb7a15d1b57496089e3eca10b9a4349b3c+dirty 1226.92 ms 1226.82 ms -0.10 ms
0db0c729a4ac7c205a44cb4702fa7ba5b0bc03c0+dirty 1258.88 ms 1262.52 ms 3.64 ms
c639edf12520d1afee79e1ff2ba18df03ce70ec3+dirty 1223.63 ms 1227.98 ms 4.35 ms
a15d3705c6400e7254598c11e8db8a705807eace+dirty 1215.00 ms 1214.75 ms -0.25 ms

App size

Revision Plain With Sentry Diff
484813b771d99e76c96e5cdea202fdc767bd7cf9+dirty 2.92 MiB 3.64 MiB 740.56 KiB
b6da94a00f2df286e3aef66616882595bf45dc04+dirty 3.19 MiB 4.33 MiB 1.14 MiB
60d7316ea11aceb94c97c4d1b926f271964e0407+dirty 3.19 MiB 4.30 MiB 1.12 MiB
9f0f6c83fbb234e0b6a3dd2897429782821da87f+dirty 2.92 MiB 3.67 MiB 771.98 KiB
4a6664fa7140687cfa079f2d738b59b18e4ac7b7+dirty 2.92 MiB 3.60 MiB 702.09 KiB
b7e707eba7c3977018d4871ede3ea2b6f7e4a3d4+dirty 3.19 MiB 4.33 MiB 1.14 MiB
f80e57eb7a15d1b57496089e3eca10b9a4349b3c+dirty 3.19 MiB 4.34 MiB 1.16 MiB
0db0c729a4ac7c205a44cb4702fa7ba5b0bc03c0+dirty 2.92 MiB 3.40 MiB 492.71 KiB
c639edf12520d1afee79e1ff2ba18df03ce70ec3+dirty 2.92 MiB 3.64 MiB 742.55 KiB
a15d3705c6400e7254598c11e8db8a705807eace+dirty 3.19 MiB 4.33 MiB 1.14 MiB

Previous results on branch: lz/fix-console

Startup times

Revision Plain With Sentry Diff
4fd28ccd81a64f39285f954e5ed682ee1770588c+dirty 1221.24 ms 1226.67 ms 5.43 ms
63aead81524449e94bc6c43487a75bd8de99b587+dirty 1237.88 ms 1232.57 ms -5.31 ms

App size

Revision Plain With Sentry Diff
4fd28ccd81a64f39285f954e5ed682ee1770588c+dirty 3.19 MiB 4.34 MiB 1.16 MiB
63aead81524449e94bc6c43487a75bd8de99b587+dirty 3.19 MiB 4.35 MiB 1.16 MiB

github-actions[bot] avatar Apr 22 '25 22:04 github-actions[bot]

The code looks good, do you have an example stack how the problematic assert gets called?

Is it inside of the symbolicateStackTrace call? It would be useful to document the stack for the future.

krystofwoldrich avatar Apr 23 '25 15:04 krystofwoldrich

The code looks good, do you have an example stack how the problematic assert gets called?

Is it inside of the symbolicateStackTrace call? It would be useful to document the stack for the future.

I actually have one here:

 LOG  Assertion called: true  message 'this' is expected an Event object, but got [{"isTrusted":false}] stack : Error
    at getCurrentStackTrace (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:125938:26)
    at anonymous (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:125950:57)
    at apply (native)
    at anonymous (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:154465:27)
    at pd (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:36235:19)
    at setPassiveListener (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:36640:7)
    at dispatchEvent (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:36939:27)
    at setReadyState (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:36129:27)
    at open (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:36041:27)
    at apply (native)
    at anonymous (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:155583:34)
    at anonymous (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:29261:17)
    at tryCallTwo (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:204678:9)
    at doResolve (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:204817:25)
    at Promise (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:204697:14)
    at fetch (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:29218:25)
    at ?anon_0_ (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28649:33)
    at next (native)
    at asyncGeneratorStep (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28665:26)
    at _next (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28684:29)
    at anonymous (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28689:14)
    at tryCallTwo (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:204678:9)
    at doResolve (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:204817:25)
    at Promise (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:204697:14)
    at anonymous (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28681:25)
    at apply (native)
    at _symbolicateStackTrace (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28658:40)
    at apply (native)
    at symbolicateStackTrace (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28637:40)
    at symbolicate (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28616:52)
    at handleSymbolicate (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28516:42)
    at symbolicate (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28507:33)
    at appendNewLog (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28152:25)
    at anonymous (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28196:21)
    at apply (native)
    at anonymous (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:35288:26)
    at _callTimer (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:35167:17)
    at _callReactNativeMicrotasksPass (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:35212:17)
    at callReactNativeMicrotasks (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:35418:44)
    at __callReactNativeMicrotasks (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:3569:48)
    at anonymous (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:3342:45)
    at __guard (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:3541:15)
    at flushedQueue (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:3341:21)
    at callFunctionReturnFlushedQueue (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:3326:33)

It is indeed inside of symbolicateStackTrace

Do you have any preference on where I could store this stack trace?

lucas-zimerman avatar Apr 23 '25 17:04 lucas-zimerman

Thank you for the stack.

I think we can add this to a comment in the code.

When looking at the stack I believe this is the most important part. It's no necessary the symbolication, but the underlying fetch call.

This is the last frame in RN before the assert happens in the shims.

https://github.com/facebook/react-native/blob/f0527d86623112eee1e80da7884081f7ecf59bea/packages/react-native/Libraries/Network/XMLHttpRequest.js#L535

at pd 
at setPassiveListener 
at dispatchEvent 
at setReadyState
at open
at Promise
at fetch

krystofwoldrich avatar Apr 24 '25 09:04 krystofwoldrich

Looking at the cause the best solution would be to use a network request which calls console.* inside of the consoleSandbox (https://github.com/getsentry/sentry-javascript/blob/bf323b111b7e7b781e60e6299e432ce89f144970/packages/core/src/utils-hoist/logger.ts#L40). That way we would avoid the regression when the error message changes or a different console.assert/error is called.

This would mean vendoring the RN symbolicate function so we can replace the fetch with out own patched fetch which calls the XMLHttpRequest functions inside of the sandbox.

The RN symbolicate fun calls fetch which calls the XMLHttpRequest.

https://github.com/facebook/react-native/blob/f0527d86623112eee1e80da7884081f7ecf59bea/packages/react-native/Libraries/Network/XMLHttpRequest.js#L97

Let me know what do you think about that?

krystofwoldrich avatar Apr 24 '25 09:04 krystofwoldrich

image here is the next commit but without the console sandbox callback

lucas-zimerman avatar Apr 24 '25 22:04 lucas-zimerman

Looking at the cause the best solution would be to use a network request which calls console.* inside of the consoleSandbox (https://github.com/getsentry/sentry-javascript/blob/bf323b111b7e7b781e60e6299e432ce89f144970/packages/core/src/utils-hoist/logger.ts#L40). That way we would avoid the regression when the error message changes or a different console.assert/error is called.

This would mean vendoring the RN symbolicate function so we can replace the fetch with out own patched fetch which calls the XMLHttpRequest functions inside of the sandbox.

The RN symbolicate fun calls fetch which calls the XMLHttpRequest.

https://github.com/facebook/react-native/blob/f0527d86623112eee1e80da7884081f7ecf59bea/packages/react-native/Libraries/Network/XMLHttpRequest.js#L97

Let me know what do you think about that?

That surely works better , I have applied your suggestion on https://github.com/getsentry/sentry-react-native/pull/4770/commits/cb9ef09a670ad9c8f36f1f24eae6be930f55bf0e

lucas-zimerman avatar Apr 24 '25 22:04 lucas-zimerman

@antonis I am closing this PR since the complexity to fix the remaining issues on it is too complex compared to the really small fix coverage it provides since the main issue of console loop no longer happens naturally.

lucas-zimerman avatar Oct 10 '25 15:10 lucas-zimerman