Skip to content

Commit 98e77e8

Browse files
iHiDclaude
andauthored
Filter student code errors from Sentry and fix async error handling (#8471) (#8492)
Student JS exercise code runs in blob URLs via the bootcamp test runner. Errors from that code (e.g. expected test failures) were reaching Sentry as unhandled promise rejections because handleRunCode called the async runCode() without await, bypassing the existing try-catch error handler. - Add Sentry beforeSend filter to drop errors from blob: URL stack frames - Await runCode() in handleRunCode so the existing error UI works - Remove stale commented-out try-catch and debug console.log Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7b441ad commit 98e77e8

3 files changed

Lines changed: 12 additions & 19 deletions

File tree

app/javascript/components/bootcamp/JikiscriptExercisePage/CodeMirror/useEditorHandler.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,13 @@ export function useEditorHandler({
9191
}
9292
}
9393

94-
const handleRunCode = () => {
94+
const handleRunCode = async () => {
9595
if (editorHandler.current) {
9696
const value = editorHandler.current.getValue()
9797

9898
setLatestValueSnapshot(value)
9999
try {
100-
//const time = performance.now()
101-
runCode(value, editorViewRef.current)
102-
//console.log('Duration', performance.now() - time)
100+
await runCode(value, editorViewRef.current)
103101
} catch (e: unknown) {
104102
if (
105103
process.env.NODE_ENV === 'development' ||

app/javascript/components/bootcamp/JikiscriptExercisePage/hooks/useConstructRunCode/useConstructRunCode.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ export function useConstructRunCode({
125125
}
126126
}
127127
)
128-
// try {
129128
testResults = await generateAndRunTestSuite(
130129
{
131130
studentCode,
@@ -143,20 +142,6 @@ export function useConstructRunCode({
143142
editorView,
144143
language
145144
)
146-
// console.log("Thinks I've run", testResults.tests.length)
147-
// } catch (error) {
148-
// console.log(error)
149-
// const compError = error as CompilationError
150-
// if (
151-
// compError.hasOwnProperty('type') &&
152-
// compError.type == 'CompilationError'
153-
// ) {
154-
// handleCompilationError(compError.error, editorView)
155-
// return
156-
// }
157-
// console.log(compError)
158-
// }
159-
console.log('No error')
160145

161146
const bonusTestResults = await generateAndRunTestSuite(
162147
{

app/javascript/utils/react-bootloader.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,16 @@ if (process.env.SENTRY_DSN) {
115115
)
116116
if (isNonErrorRejection) return null
117117

118+
// Drop errors from student code running in blob URLs (bootcamp JS
119+
// exercises execute student solutions via dynamically created blob:
120+
// modules — errors from those are expected, not application bugs)
121+
const isStudentCodeError = event.exception?.values?.some((ex) =>
122+
ex.stacktrace?.frames?.some((frame) =>
123+
frame.filename?.startsWith('blob:')
124+
)
125+
)
126+
if (isStudentCodeError) return null
127+
118128
const tag = document.querySelector<HTMLMetaElement>(
119129
'meta[name="user-id"]'
120130
)

0 commit comments

Comments
 (0)