Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io) as well as self-hosted (same issue occurs in both environments).
Which SDK are you using?
@sentry/sveltekit
SDK Version
7.74.1
Framework Version
1.26.0
Link to Sentry event
https://zenthropic.sentry.io/issues/4559398012/?project=4504934292258816
SDK Setup
Sentry.init({
dsn: 'https://3365729f7ba44228b319f4ad7ae32e6a@o4504934289506304.ingest.sentry.io/4504934292258816',
tracesSampleRate: 1.0,
});
Steps to Reproduce
I created a new minimum SvelteKit repro with Sentry to demonstrate this bug.
- Create new SvelteKit project
npm create svelte@latest sentry-repro
# - Skeleton project
# - Yes, using TypeScript syntax
# - skip other add-ons
cd sentry-repro
npm i
- Add Sentry using setup wizard
npx @sentry/wizard@latest -i sveltekit
# - Sentry SaaS
# - yes
# - select project
- Add a
src/routes/+page.ts file with a TypeScript <> cast operator
export async function load() {
let x: unknown = 'foo';
console.log(<string>x);
}
- Start dev server and open the page
npm run dev
# http://localhost:5173/
- Note the error:
Internal server error: Unterminated JSX contents. (3:22)
- Modify
vite.config.ts to disable auto-instrumentation:
// add sentrySvelteKit config option
autoInstrument: false
- Note that the error goes away / page serves as expected
Expected Result
No error should occur at step 5.
Auto-instrumentation should not (incorrectly) interpret TypeScript cast operator <> as JSX.
Current work-around: using as cast operator instead of <>.
Actual Result
The following error occurs at step 5.
Unterminated JSX contents. (3:22)
SyntaxError: Unterminated JSX contents. (3:22)
at constructor (/Users/ken/Code/sentry-repro/node_modules/@babel/parser/lib/index.js:356:19)
at V8IntrinsicMixin.raise (/Users/ken/Code/sentry-repro/node_modules/@babel/parser/lib/index.js:3223:19)
at V8IntrinsicMixin.jsxReadToken (/Users/ken/Code/sentry-repro/node_modules/@babel/parser/lib/index.js:6605:20)
at V8IntrinsicMixin.getTokenFromCode (/Users/ken/Code/sentry-repro/node_modules/@babel/parser/lib/index.js:6947:12)
at V8IntrinsicMixin.getTokenFromCode (/Users/ken/Code/sentry-repro/node_modules/@babel/parser/lib/index.js:9852:11)
at V8IntrinsicMixin.nextToken (/Users/ken/Code/sentry-repro/node_modules/@babel/parser/lib/index.js:2347:10)
at V8IntrinsicMixin.next (/Users/ken/Code/sentry-repro/node_modules/@babel/parser/lib/index.js:2258:10)
at V8IntrinsicMixin.eat (/Users/ken/Code/sentry-repro/node_modules/@babel/parser/lib/index.js:2262:12)
at V8IntrinsicMixin.expect (/Users/ken/Code/sentry-repro/node_modules/@babel/parser/lib/index.js:3590:10)
at V8IntrinsicMixin.jsxParseOpeningElementAfterName (/Users/ken/Code/sentry-repro/node_modules/@babel/parser/lib/index.js:6836:10
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io) as well as self-hosted (same issue occurs in both environments).
Which SDK are you using?
@sentry/sveltekit
SDK Version
7.74.1
Framework Version
1.26.0
Link to Sentry event
https://zenthropic.sentry.io/issues/4559398012/?project=4504934292258816
SDK Setup
Steps to Reproduce
I created a new minimum SvelteKit repro with Sentry to demonstrate this bug.
src/routes/+page.tsfile with a TypeScript<>cast operatornpm run dev # http://localhost:5173/vite.config.tsto disable auto-instrumentation:Expected Result
No error should occur at step 5.
Auto-instrumentation should not (incorrectly) interpret TypeScript cast operator
<>as JSX.Current work-around: using
ascast operator instead of<>.Actual Result
The following error occurs at step 5.