Skip to content

Commit d7ca21e

Browse files
gggritsoclaude
andcommitted
fix(insights): End Sentry span in finally block, improve jest config comment
Move sentrySpan.end() to a finally block to prevent span leaks on parse errors. Clarify moduleNameMapper comment explaining why the manual paths are needed (ESM-only exports with no require condition). Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 0775ea1 commit d7ca21e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

jest.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ const config: Config.InitialOptions = {
308308
'^echarts/(.*)': '<rootDir>/tests/js/sentry-test/mocks/echartsMock.js',
309309
'^zrender/(.*)': '<rootDir>/tests/js/sentry-test/mocks/echartsMock.js',
310310

311-
// @sentry/sqlish uses ESM exports which Jest can't resolve directly
311+
// @sentry/sqlish is ESM-only with `exports` that only define `import`
312+
// conditions. Jest's CJS resolver can't follow them without explicit mapping.
312313
'^@sentry/sqlish/react$': '<rootDir>/node_modules/@sentry/sqlish/dist/react.js',
313314
'^@sentry/sqlish$': '<rootDir>/node_modules/@sentry/sqlish/dist/index.js',
314315

static/app/utils/sqlish.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export class SQLishFormatter {
4242

4343
try {
4444
const result = fn();
45-
sentrySpan?.end();
4645
return result;
4746
} catch (error: any) {
4847
Sentry.withScope(scope => {
@@ -63,6 +62,8 @@ export class SQLishFormatter {
6362

6463
// If we fail to parse the SQL, return the original string
6564
return sql as unknown as T;
65+
} finally {
66+
sentrySpan?.end();
6667
}
6768
}
6869
}

0 commit comments

Comments
 (0)