Skip to content

Commit d44a0cd

Browse files
author
Stephen Cefali
authored
feat(sourcemaps): hide sourcemap not found error (#46153)
Now that we have the in-app source map debugging, we can hide the source map file not found error. Note there are other possible source map errors that we don't hide because they do provide additional information on top of the in-app source map debugging. But this is just a temporary state until we start using the debug ID strategy for sourcemaps. Once we have that in place, we will overhaul the instructions and hide more errors related to sourcemaps. ![Screen Shot 2023-03-21 at 2 33 02 PM](https://user-images.githubusercontent.com/8533851/226746066-f42e553c-ad09-4990-aa37-119f6f15c121.png)
1 parent 32c147e commit d44a0cd

File tree

2 files changed

+17
-96
lines changed

2 files changed

+17
-96
lines changed

static/app/components/events/eventErrors.spec.tsx

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -56,38 +56,17 @@ describe('EventErrors', () => {
5656
).toBeInTheDocument();
5757
});
5858

59-
describe('release artifacts', () => {
60-
it('displays extra error info when event dist does not match file dist', async () => {
61-
const mock = MockApiClient.addMockResponse({
62-
url: '/projects/org-slug/project-slug/releases/release-version/files/',
63-
body: [{name: 'dist-1'}],
64-
});
65-
66-
const eventWithDifferentDist = TestStubs.Event({
67-
release: {
68-
version: 'release-version',
59+
it('hides source map not found error', () => {
60+
const eventWithDifferentDist = TestStubs.Event({
61+
errors: [
62+
{
63+
type: JavascriptProcessingErrors.JS_MISSING_SOURCE,
6964
},
70-
errors: [
71-
{
72-
type: JavascriptProcessingErrors.JS_MISSING_SOURCE,
73-
data: {
74-
url: 'https://place.com/dist-2',
75-
},
76-
},
77-
],
78-
});
79-
80-
render(<EventErrors {...defaultProps} event={eventWithDifferentDist} />);
81-
82-
await userEvent.click(
83-
screen.getByText(/there was 1 problem processing this event/i)
84-
);
85-
86-
expect(mock).toHaveBeenCalled();
87-
await screen.findByText(
88-
/Source code was not found because the distribution did not match/i
89-
);
65+
],
9066
});
67+
68+
render(<EventErrors {...defaultProps} event={eventWithDifferentDist} />);
69+
expect(screen.queryByText(/problem processing this event/i)).not.toBeInTheDocument();
9170
});
9271

9372
describe('proguard errors', () => {

static/app/components/events/eventErrors.tsx

Lines changed: 8 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import getThreadException from 'sentry/components/events/interfaces/threads/thre
1111
import ExternalLink from 'sentry/components/links/externalLink';
1212
import List from 'sentry/components/list';
1313
import {JavascriptProcessingErrors} from 'sentry/constants/eventErrors';
14-
import {t, tct, tn} from 'sentry/locale';
14+
import {tct, tn} from 'sentry/locale';
1515
import {space} from 'sentry/styles/space';
16-
import {Artifact, Project} from 'sentry/types';
16+
import {Project} from 'sentry/types';
1717
import {DebugFile} from 'sentry/types/debugFiles';
1818
import {Image} from 'sentry/types/debugImage';
1919
import {EntryType, Event, ExceptionValue, Thread} from 'sentry/types/event';
@@ -25,6 +25,8 @@ import {projectProcessingIssuesMessages} from 'sentry/views/settings/project/pro
2525

2626
import {DataSection} from './styles';
2727

28+
const ERRORS_TO_HIDE = [JavascriptProcessingErrors.JS_MISSING_SOURCE];
29+
2830
const MAX_ERRORS = 100;
2931
const MINIFIED_DATA_JAVA_EVENT_REGEX_MATCH =
3032
/^(([\w\$]\.[\w\$]{1,2})|([\w\$]{2}\.[\w\$]\.[\w\$]))(\.|$)/g;
@@ -43,14 +45,6 @@ function isDataMinified(str: string | null) {
4345
return !![...str.matchAll(MINIFIED_DATA_JAVA_EVENT_REGEX_MATCH)].length;
4446
}
4547

46-
const getURLPathname = (url: string) => {
47-
try {
48-
return new URL(url).pathname;
49-
} catch {
50-
return undefined;
51-
}
52-
};
53-
5448
const hasThreadOrExceptionMinifiedFrameData = (
5549
definedEvent: Event,
5650
bestThread?: Thread
@@ -189,28 +183,6 @@ const useFetchProguardMappingFiles = ({
189183
};
190184
};
191185

192-
const useFetchReleaseArtifacts = ({event, project}: {event: Event; project: Project}) => {
193-
const organization = useOrganization();
194-
const releaseVersion = event.release?.version;
195-
const pathNames = (event.errors ?? [])
196-
.filter(
197-
error =>
198-
error.type === 'js_no_source' && error.data.url && getURLPathname(error.data.url)
199-
)
200-
.map(sourceCodeError => getURLPathname(sourceCodeError.data.url));
201-
const {data: releaseArtifacts} = useQuery<Artifact[]>(
202-
[
203-
`/projects/${organization.slug}/${project.slug}/releases/${encodeURIComponent(
204-
releaseVersion ?? ''
205-
)}/files/`,
206-
{query: {query: pathNames}},
207-
],
208-
{staleTime: Infinity, enabled: pathNames.length > 0 && defined(releaseVersion)}
209-
);
210-
211-
return releaseArtifacts;
212-
};
213-
214186
const useRecordAnalyticsEvent = ({event, project}: {event: Event; project: Project}) => {
215187
const organization = useOrganization();
216188

@@ -239,7 +211,6 @@ const useRecordAnalyticsEvent = ({event, project}: {event: Event; project: Proje
239211
export const EventErrors = ({event, project, isShare}: EventErrorsProps) => {
240212
const organization = useOrganization();
241213
useRecordAnalyticsEvent({event, project});
242-
const releaseArtifacts = useFetchReleaseArtifacts({event, project});
243214
const {proguardErrorsLoading, proguardErrors} = useFetchProguardMappingFiles({
244215
event,
245216
project,
@@ -272,13 +243,15 @@ export const EventErrors = ({event, project, isShare}: EventErrorsProps) => {
272243
// eslint-disable-next-line react-hooks/exhaustive-deps
273244
}, []);
274245

275-
const {dist: eventDistribution, errors: eventErrors = [], _meta} = event;
246+
const {errors: eventErrors = [], _meta} = event;
276247

277248
// XXX: uniqWith returns unique errors and is not performant with large datasets
278249
const otherErrors: Array<EventErrorData> =
279250
eventErrors.length > MAX_ERRORS ? eventErrors : uniqWith(eventErrors, isEqual);
280251

281-
const errors = [...otherErrors, ...proguardErrors];
252+
const errors = [...otherErrors, ...proguardErrors].filter(
253+
error => !ERRORS_TO_HIDE.includes(error.type as JavascriptProcessingErrors)
254+
);
282255

283256
if (proguardErrorsLoading) {
284257
// XXX: This is necessary for acceptance tests to wait until removal since there is
@@ -301,37 +274,6 @@ export const EventErrors = ({event, project, isShare}: EventErrorsProps) => {
301274
{errors.map((error, errorIdx) => {
302275
const data = error.data ?? {};
303276
const meta = _meta?.errors?.[errorIdx];
304-
305-
if (
306-
error.type === JavascriptProcessingErrors.JS_MISSING_SOURCE &&
307-
data.url &&
308-
!!releaseArtifacts?.length
309-
) {
310-
const releaseArtifact = releaseArtifacts.find(releaseArt => {
311-
const pathname = data.url ? getURLPathname(data.url) : undefined;
312-
313-
if (pathname) {
314-
return releaseArt.name.includes(pathname);
315-
}
316-
return false;
317-
});
318-
319-
const releaseArtifactDistribution = releaseArtifact?.dist ?? null;
320-
321-
// Neither event nor file have dist -> matching
322-
// Event has dist, file doesn’t -> not matching
323-
// File has dist, event doesn’t -> not matching
324-
// Both have dist, same value -> matching
325-
// Both have dist, different values -> not matching
326-
if (releaseArtifactDistribution !== eventDistribution) {
327-
error.message = t(
328-
'Source code was not found because the distribution did not match'
329-
);
330-
data['expected-distribution'] = eventDistribution;
331-
data['current-distribution'] = releaseArtifactDistribution;
332-
}
333-
}
334-
335277
return <ErrorItem key={errorIdx} error={{...error, data}} meta={meta} />;
336278
})}
337279
</ErrorList>

0 commit comments

Comments
 (0)