Skip to content

Commit 9c786a3

Browse files
authored
feat(expo): Only upload Expo artifact if source map exists (#3568)
1 parent eb53e59 commit 9c786a3

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
});
1818
```
1919

20+
- Only upload Expo artifact if source map exists ([#3568](https://github.com/getsentry/sentry-react-native/pull/3568))
21+
2022
### Fixes
2123

2224
- Prevent pod install crash when visionos is not present ([#3548](https://github.com/getsentry/sentry-react-native/pull/3548))

scripts/expo-upload-sourcemaps.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ if (!outputDir) {
137137
const files = getAssetPathsSync(outputDir);
138138
const groupedAssets = groupAssets(files);
139139

140+
const totalAssets = Object.keys(groupedAssets).length;
141+
let numAssetsUploaded = 0;
140142
for (const [assetGroupName, assets] of Object.entries(groupedAssets)) {
141143
const sourceMapPath = assets.find(asset => asset.endsWith('.map'));
142144
if (sourceMapPath) {
@@ -145,8 +147,12 @@ for (const [assetGroupName, assets] of Object.entries(groupedAssets)) {
145147
sourceMap.debug_id = sourceMap.debugId;
146148
}
147149
writeJSONFile(sourceMapPath, sourceMap);
150+
console.log(`⬆️ Uploading ${assetGroupName} bundle and sourcemap...`);
151+
} else {
152+
console.log(`❓ Sourcemap for ${assetGroupName} not found, skipping...`);
153+
continue;
148154
}
149-
console.log(`⬆️ Uploading ${assetGroupName} bundle and sourcemap...`);
155+
150156
const isHermes = assets.find(asset => asset.endsWith('.hbc'));
151157
execSync(`${sentryCliBin} sourcemaps upload ${isHermes ? '--debug-id-reference' : ''} ${assets.join(' ')}`, {
152158
env: {
@@ -155,6 +161,15 @@ for (const [assetGroupName, assets] of Object.entries(groupedAssets)) {
155161
},
156162
stdio: 'inherit',
157163
});
164+
numAssetsUploaded++;
158165
}
159166

160-
console.log('✅ Uploaded bundles and sourcemaps to Sentry successfully.');
167+
if (numAssetsUploaded === totalAssets) {
168+
console.log('✅ Uploaded bundles and sourcemaps to Sentry successfully.');
169+
} else {
170+
console.warn(
171+
`⚠️ Uploaded ${numAssetsUploaded} of ${totalAssets} bundles and sourcemaps. ${
172+
numAssetsUploaded === 0 ? 'Ensure you are running `expo export` with the `--dump-sourcemap` flag.' : ''
173+
}`,
174+
);
175+
}

0 commit comments

Comments
 (0)