Skip to content

Fix SDK Build when using PnPM #4977

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

Merged
merged 6 commits into from
Jul 17, 2025
Merged

Fix SDK Build when using PnPM #4977

merged 6 commits into from
Jul 17, 2025

Conversation

lucas-zimerman
Copy link
Collaborator

@lucas-zimerman lucas-zimerman commented Jul 8, 2025

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

PNPM has a different way of linking sub modules, breaking commong node resolution for @sentry/cli.

💡 Motivation and Context

The fix is try to get the @sentry/cli the original way. If that fails, try to read the file that pnpm generated, when parsing that file we can check the exact location that pnpm stored @sentry/cli on the project.

Example of the file generated by PNPM sentry-cli:

image

#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*|*MINGW*|*MSYS*)
        if command -v cygpath > /dev/null 2>&1; then
            basedir=`cygpath -w "$basedir"`
        fi
    ;;
esac

if [ -z "$NODE_PATH" ]; then
  export NODE_PATH="/HOME.../expo-app/node_modules/.pnpm/@[email protected]/node_modules/@sentry/cli/bin/node_modules:/HOME.../expo-app/node_modules/.pnpm/@[email protected]/node_modules/@sentry/cli/node_modules:/HOME.../expo-app/node_modules/.pnpm/@[email protected]/node_modules/@sentry/node_modules:/HOME.../expo-app/node_modules/.pnpm/@[email protected]/node_modules:/HOME.../expo-app/node_modules/.pnpm/node_modules"
else
  export NODE_PATH="/HOME.../expo-app/node_modules/.pnpm/@[email protected]/node_modules/@sentry/cli/bin/node_modules:/HOME.../expo-app/node_modules/.pnpm/@[email protected]/node_modules/@sentry/cli/node_modules:/HOME.../expo-app/node_modules/.pnpm/@[email protected]/node_modules/@sentry/node_modules:/HOME.../expo-app/node_modules/.pnpm/@[email protected]/node_modules:/HOME.../expo-app/node_modules/.pnpm/node_modules:$NODE_PATH"
fi
if [ -x "$basedir/node" ]; then
  exec "$basedir/node"  "$basedir/../../../../../../@[email protected]/node_modules/@sentry/cli/bin/sentry-cli" "$@"
else
  exec node  "$basedir/../../../../../../@[email protected]/node_modules/@sentry/cli/bin/sentry-cli" "$@"
fi

image

Fixes #4939

💚 How did you test it?

On a Linux and MacOS device doing production builds.

📝 Checklist

  • I added tests to verify changes
  • 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
  • No breaking changes

🔮 Next steps

Copy link
Contributor

github-actions bot commented Jul 8, 2025

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 382.49 ms 408.30 ms 25.81 ms
Size 7.15 MiB 8.42 MiB 1.27 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
a3aad2b+dirty 389.53 ms 436.76 ms 47.23 ms
940bd65+dirty 408.45 ms 419.75 ms 11.30 ms
f25ae46+dirty 366.14 ms 367.96 ms 1.82 ms
531450c+dirty 337.17 ms 362.67 ms 25.50 ms
ab18954+dirty 376.65 ms 376.82 ms 0.17 ms
38a1af2+dirty 421.38 ms 431.35 ms 9.97 ms
f76175c+dirty 354.23 ms 378.20 ms 23.97 ms
6715c24+dirty 378.57 ms 417.54 ms 38.97 ms
ba41c2a+dirty 376.50 ms 388.62 ms 12.12 ms
6e8a851+dirty 403.44 ms 430.87 ms 27.43 ms

App size

Revision Plain With Sentry Diff
a3aad2b+dirty 7.15 MiB 8.42 MiB 1.26 MiB
940bd65+dirty 7.15 MiB 8.42 MiB 1.26 MiB
f25ae46+dirty 7.15 MiB 8.42 MiB 1.26 MiB
531450c+dirty 7.15 MiB 8.42 MiB 1.26 MiB
ab18954+dirty 7.15 MiB 8.42 MiB 1.26 MiB
38a1af2+dirty 7.15 MiB 8.42 MiB 1.26 MiB
f76175c+dirty 7.15 MiB 8.42 MiB 1.26 MiB
6715c24+dirty 7.15 MiB 8.42 MiB 1.27 MiB
ba41c2a+dirty 7.15 MiB 8.42 MiB 1.26 MiB
6e8a851+dirty 7.15 MiB 8.42 MiB 1.26 MiB

Previous results on branch: lz/test-pnpm

Startup times

Revision Plain With Sentry Diff
7c3c868+dirty 348.36 ms 356.13 ms 7.77 ms

App size

Revision Plain With Sentry Diff
7c3c868+dirty 7.15 MiB 8.42 MiB 1.26 MiB

Copy link
Contributor

github-actions bot commented Jul 8, 2025

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 459.02 ms 458.98 ms -0.04 ms
Size 17.75 MiB 20.15 MiB 2.41 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
a3aad2b 453.57 ms 463.62 ms 10.05 ms
c352c30 331.98 ms 321.78 ms -10.20 ms
e12044e 453.78 ms 437.58 ms -16.20 ms
531450c 426.69 ms 427.31 ms 0.62 ms
26286ef 371.31 ms 355.34 ms -15.97 ms
ab18954 433.46 ms 436.84 ms 3.38 ms
b13b9dd 465.46 ms 470.83 ms 5.37 ms
f2c6fa5 445.15 ms 449.13 ms 3.98 ms
7d3c3cb 444.85 ms 456.65 ms 11.81 ms
071ae5c 393.64 ms 406.60 ms 12.96 ms

App size

Revision Plain With Sentry Diff
a3aad2b 17.75 MiB 20.15 MiB 2.40 MiB
c352c30 17.75 MiB 20.15 MiB 2.40 MiB
e12044e 17.75 MiB 20.15 MiB 2.40 MiB
531450c 17.75 MiB 20.15 MiB 2.40 MiB
26286ef 17.75 MiB 20.15 MiB 2.40 MiB
ab18954 17.75 MiB 20.15 MiB 2.40 MiB
b13b9dd 17.75 MiB 20.15 MiB 2.41 MiB
f2c6fa5 17.75 MiB 20.15 MiB 2.40 MiB
7d3c3cb 17.75 MiB 20.15 MiB 2.40 MiB
071ae5c 17.75 MiB 20.15 MiB 2.41 MiB

Previous results on branch: lz/test-pnpm

Startup times

Revision Plain With Sentry Diff
7c3c868 403.08 ms 423.79 ms 20.71 ms

App size

Revision Plain With Sentry Diff
7c3c868 17.75 MiB 20.15 MiB 2.40 MiB

Copy link
Contributor

github-actions bot commented Jul 8, 2025

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1226.53 ms 1239.44 ms 12.91 ms
Size 3.19 MiB 4.36 MiB 1.17 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
bd87539+dirty 1233.71 ms 1229.77 ms -3.94 ms
1a14c8b+dirty 1226.04 ms 1236.96 ms 10.92 ms
531450c+dirty 1225.94 ms 1229.65 ms 3.71 ms
4e2cbd2+dirty 1207.25 ms 1217.52 ms 10.27 ms
398e5d0+dirty 1226.17 ms 1232.82 ms 6.65 ms
ec2a485+dirty 1209.65 ms 1229.18 ms 19.53 ms
d18ddb1+dirty 1200.88 ms 1214.57 ms 13.69 ms
7d3c3cb+dirty 1214.56 ms 1234.53 ms 19.97 ms
38a1af2+dirty 1211.57 ms 1219.27 ms 7.70 ms
9167f73+dirty 1219.47 ms 1234.39 ms 14.92 ms

App size

Revision Plain With Sentry Diff
bd87539+dirty 3.19 MiB 4.36 MiB 1.17 MiB
1a14c8b+dirty 3.19 MiB 4.36 MiB 1.17 MiB
531450c+dirty 3.19 MiB 4.36 MiB 1.17 MiB
4e2cbd2+dirty 3.19 MiB 4.35 MiB 1.17 MiB
398e5d0+dirty 3.19 MiB 4.35 MiB 1.17 MiB
ec2a485+dirty 3.19 MiB 4.35 MiB 1.17 MiB
d18ddb1+dirty 3.19 MiB 4.36 MiB 1.17 MiB
7d3c3cb+dirty 3.19 MiB 4.35 MiB 1.16 MiB
38a1af2+dirty 3.19 MiB 4.35 MiB 1.17 MiB
9167f73+dirty 3.19 MiB 4.35 MiB 1.17 MiB

Copy link
Contributor

github-actions bot commented Jul 8, 2025

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1222.33 ms 1230.02 ms 7.69 ms
Size 2.63 MiB 3.80 MiB 1.17 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
bd87539+dirty 1219.29 ms 1220.09 ms 0.80 ms
1a14c8b+dirty 1213.39 ms 1207.80 ms -5.60 ms
531450c+dirty 1226.67 ms 1233.10 ms 6.43 ms
4e2cbd2+dirty 1223.00 ms 1236.12 ms 13.12 ms
398e5d0+dirty 1225.30 ms 1219.94 ms -5.36 ms
d18ddb1+dirty 1209.74 ms 1209.65 ms -0.10 ms
38a1af2+dirty 1210.07 ms 1212.75 ms 2.68 ms
9167f73+dirty 1230.79 ms 1230.63 ms -0.17 ms
bdb324a+dirty 1229.33 ms 1236.61 ms 7.29 ms
940bd65+dirty 1216.88 ms 1225.23 ms 8.35 ms

App size

Revision Plain With Sentry Diff
bd87539+dirty 2.63 MiB 3.80 MiB 1.17 MiB
1a14c8b+dirty 2.63 MiB 3.80 MiB 1.17 MiB
531450c+dirty 2.63 MiB 3.80 MiB 1.17 MiB
4e2cbd2+dirty 2.63 MiB 3.79 MiB 1.15 MiB
398e5d0+dirty 2.63 MiB 3.79 MiB 1.15 MiB
d18ddb1+dirty 2.63 MiB 3.80 MiB 1.17 MiB
38a1af2+dirty 2.63 MiB 3.79 MiB 1.15 MiB
9167f73+dirty 2.63 MiB 3.79 MiB 1.15 MiB
bdb324a+dirty 2.63 MiB 3.79 MiB 1.15 MiB
940bd65+dirty 2.63 MiB 3.78 MiB 1.15 MiB

@lucas-zimerman
Copy link
Collaborator Author

After further validation
expo-upload-sourcemaps.js doesn't need patching since pnpm correctly points to the correctly directory where the script can find @sentry/cli

pnpm sentry-expo-upload-sourcemaps dist
env: load .env
env: export SENTRY_AUTH_TOKEN
/Volumes/.../Archive/node_modules/.pnpm/@[email protected]/node_modules/@sentry/cli/bin/sentry-cli is here
🐕 Fetching from expo config...
SENTRY_ORG resolved to sentry-sdks from expo config.
SENTRY_PROJECT resolved to sentry-react-native from expo config.
SENTRY_URL resolved to https://sentry.io/ from expo config.
⬆️ Uploading dist/_expo/static/js/web/entry-31a89b438b8340134075395a55b1087e.js bundle and sourcemap...
  WARN    2025-07-16 12:44:18.664514 -03:00 Using https://sentry.io (embedded in token) rather than manually-configured URL https://sentry.io/. To use https://sentry.io/, please provide an  auth token for https://sentry.io/.
> Found 1 file
> Found 1 file
> Analyzing 2 sources
> Analyzing completed in 0.013s
> Rewriting sources
> Rewriting completed in 0.103s
> Adding source map references
> Bundling completed in 0.272s
> Bundled 2 files for upload
> Bundle ID: 8cd136ac-faa2-5288-82d5-941d52d77ff1
> Optimizing completed in 0.007s
> Nothing to upload, all files are on the server
> Processing completed in 0.687s
> File upload complete (processing pending on server)
> Organization: sentry-sdks
> Projects: sentry-react-native
> Release: None
> Dist: None
> Upload type: artifact bundle

@lucas-zimerman lucas-zimerman marked this pull request as ready for review July 16, 2025 15:46
@lucas-zimerman lucas-zimerman requested a review from antonis as a code owner July 16, 2025 15:46
Copy link
Collaborator

@antonis antonis left a comment

Choose a reason for hiding this comment

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

Thank you for fixing this @lucas-zimerman 🙇
LGTM 🎸

@antonis antonis merged commit 4f13db0 into main Jul 17, 2025
84 of 88 checks passed
@antonis antonis deleted the lz/test-pnpm branch July 17, 2025 10:36
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.

Pnpm package manager iOS ARCHIVE FAILED (Cannot find module '@sentry/cli/package.json')
2 participants