Skip to content
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

fix(expo): Do not run the SDK during static routes generation #3730

Merged
merged 4 commits into from
Apr 9, 2024

Conversation

krystofwoldrich
Copy link
Member

📢 Type of change

  • Bugfix

📜 Description

Before this PR the Sentry RN SDK would be initialized during static routes generation by expo-router. This could cause issues as the SDK is not prepared to run on the server side. This behavior pollutes the dev server and export command logs.

Before: See the duplicate WARN labels caused by the SDK init.
Screenshot 2024-04-02 at 19 32 58

💚 How did you test it?

sample app

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled
  • All tests passing
  • No breaking changes

🔮 Next steps

Copy link
Collaborator

@lucas-zimerman lucas-zimerman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

github-actions bot commented Apr 4, 2024

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 452.58 ms 494.98 ms 42.40 ms
Size 17.73 MiB 19.93 MiB 2.20 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
e2b64fe 316.88 ms 330.23 ms 13.35 ms
3ffcddd 302.92 ms 315.80 ms 12.88 ms
70caa60+dirty 299.00 ms 321.02 ms 22.02 ms
abb7058 370.27 ms 389.58 ms 19.31 ms
80b2ce3 385.02 ms 387.36 ms 2.34 ms
9433f35 347.64 ms 356.22 ms 8.58 ms
0677344 327.74 ms 337.14 ms 9.40 ms
52a8031+dirty 311.55 ms 321.37 ms 9.82 ms
0db0c72 372.12 ms 386.00 ms 13.88 ms
3853f43 329.68 ms 346.32 ms 16.64 ms

App size

Revision Plain With Sentry Diff
e2b64fe 17.73 MiB 19.80 MiB 2.07 MiB
3ffcddd 17.73 MiB 19.75 MiB 2.02 MiB
70caa60+dirty 17.73 MiB 19.75 MiB 2.01 MiB
abb7058 17.73 MiB 19.83 MiB 2.10 MiB
80b2ce3 17.73 MiB 19.75 MiB 2.02 MiB
9433f35 17.73 MiB 19.81 MiB 2.08 MiB
0677344 17.73 MiB 19.81 MiB 2.07 MiB
52a8031+dirty 17.73 MiB 20.04 MiB 2.31 MiB
0db0c72 17.73 MiB 19.75 MiB 2.02 MiB
3853f43 17.73 MiB 19.81 MiB 2.08 MiB

Copy link
Contributor

github-actions bot commented Apr 4, 2024

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1235.15 ms 1235.71 ms 0.56 ms
Size 2.92 MiB 3.48 MiB 575.68 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
0db0c72+dirty 1258.88 ms 1262.52 ms 3.64 ms
9433f35+dirty 1232.24 ms 1232.74 ms 0.50 ms
76d1baf+dirty 1245.00 ms 1257.76 ms 12.76 ms
e2b64fe+dirty 1285.78 ms 1297.56 ms 11.78 ms
8900e1a+dirty 1268.36 ms 1273.04 ms 4.68 ms
e73f4ed+dirty 1282.90 ms 1309.30 ms 26.40 ms
3853f43+dirty 1271.74 ms 1278.04 ms 6.30 ms
27ef4ee+dirty 1236.41 ms 1244.90 ms 8.49 ms
d7401ac+dirty 1288.10 ms 1289.54 ms 1.44 ms
22e31b6+dirty 1276.55 ms 1278.12 ms 1.57 ms

App size

Revision Plain With Sentry Diff
0db0c72+dirty 2.92 MiB 3.40 MiB 492.71 KiB
9433f35+dirty 2.92 MiB 3.41 MiB 503.55 KiB
76d1baf+dirty 2.92 MiB 3.38 MiB 475.74 KiB
e2b64fe+dirty 2.92 MiB 3.41 MiB 499.97 KiB
8900e1a+dirty 2.92 MiB 3.39 MiB 485.96 KiB
e73f4ed+dirty 2.92 MiB 3.38 MiB 475.71 KiB
3853f43+dirty 2.92 MiB 3.41 MiB 503.54 KiB
27ef4ee+dirty 2.92 MiB 3.41 MiB 503.72 KiB
d7401ac+dirty 2.92 MiB 3.40 MiB 488.06 KiB
22e31b6+dirty 2.92 MiB 3.43 MiB 524.74 KiB

@lucas-zimerman lucas-zimerman merged commit c56834a into main Apr 9, 2024
54 of 56 checks passed
@lucas-zimerman lucas-zimerman deleted the kw-fix-static-routes-expo branch April 9, 2024 16:25
byCedric added a commit to expo/expo that referenced this pull request Jul 16, 2024
# Why

Instead of force-closing the process, this gives the process a bit of
time before exiting. With this, we could catch problems around open
handles and send telemetry info if they start happening again.

The telemetry would be more useful if we also capture dependencies
whenever this happens, e.g. `@sentry/react-native` was known to freeze
static rendering export ([fixed
here](getsentry/sentry-react-native#3730))

# How

- Added `ensureProcessExitsAfterDelay`
  - This is a simple `setTimeout` with a maximum delay of 10s
- It uses
[`process.getActiveResourcesInfo()`](https://nodejs.org/docs/latest-v18.x/api/process.html#processgetactiveresourcesinfo)
  - Logs resource information through debug logs (no telemetry yet)


# Test Plan

`DEBUG=expo:utils:exit expod export ...` should show:


![image](https://github.com/expo/expo/assets/1203991/9c7a0a8f-33aa-4a9c-9894-427e3c4786fe)

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants