Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
my-code | c95258b | Commit Preview URL Branch Preview URL |
Apr 19 2026, 08:07 AM |
d531295 to
d01e487
Compare
* chore: plan runtime fatal error handling changes Agent-Logs-Url: https://github.com/ut-code/my-code/sessions/3499a4d7-2b75-4046-b6d5-24912d4eaf0a Co-authored-by: na-trium-144 <100704180+na-trium-144@users.noreply.github.com> * feat(runtime): add fatalError and onError callback propagation Agent-Logs-Url: https://github.com/ut-code/my-code/sessions/3499a4d7-2b75-4046-b6d5-24912d4eaf0a Co-authored-by: na-trium-144 <100704180+na-trium-144@users.noreply.github.com> * revert package-lock.json * fix: restore package-lock from sentry to prevent dependency drift Agent-Logs-Url: https://github.com/ut-code/my-code/sessions/f1dea2f9-037f-4cd9-a9e0-cefe2e569bfa Co-authored-by: na-trium-144 <100704180+na-trium-144@users.noreply.github.com> * fix(runtime): avoid bundling typescript.js in server handler Agent-Logs-Url: https://github.com/ut-code/my-code/sessions/1f1e6587-2ca0-4873-86cf-5cc4025a539b Co-authored-by: na-trium-144 <100704180+na-trium-144@users.noreply.github.com> * fatalErrorをそんなに目立たせる必要ない * handleRuntimeErrorをplainの関数にし、alertを追加 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: na-trium-144 <100704180+na-trium-144@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Sentry(Bugsink)をNext.jsアプリに導入し、クライアント/サーバ/Edgeのエラー収集と、ランタイム(WebWorker/Wandbox/TypeScript等)側の“致命的エラー”検知・通知を統一的に扱えるようにするPRです。
Changes:
- Sentryの初期化(server/edge/client)とNext設定(withSentryConfig、tunnel、bundle最適化)を追加
- ランタイム層に
onErrorコールバックとfatalError出力タイプを導入し、UI側で捕捉できるように拡張 - エラーページ表示を共通コンポーネント(
ErrorMessage)に集約し、API/Server Actions/Chat周りでもcaptureExceptionを追加
Reviewed changes
Copilot reviewed 29 out of 30 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| sentry.server.config.ts | Sentry(server)初期化を追加 |
| sentry.edge.config.ts | Sentry(edge)初期化を追加 |
| instrumentation.ts | Next instrumentation で server/edge 設定を読み込み、onRequestError を設定 |
| instrumentation-client.ts | client 側Sentry初期化と router transition hook を追加 |
| next.config.ts | withSentryConfig 適用、バンドル/トレース設定を追加 |
| package.json | @sentry/nextjs を追加 |
| packages/runtime/src/interface.ts | RuntimeErrorHandler と fatalError を型/Schemaに追加、init に onError を追加 |
| packages/runtime/src/context.tsx | useRuntime に onError オプションを追加して init(onError) を呼ぶよう変更 |
| packages/runtime/src/worker/runtime.tsx | Worker初期化/実行時の例外を onError に転送、fatalError を扱うよう拡張 |
| packages/runtime/src/worker/ruby.worker.ts | Ruby側エラーを fatal/non-fatal に分類して出力タイプを切替 |
| packages/runtime/src/worker/pyodide.worker.ts | 予期せぬ例外を fatalError として出力 |
| packages/runtime/src/wandbox/runtime.tsx | Wandboxの取得失敗/実行例外を onError と fatalError 出力へ |
| packages/runtime/src/typescript/runtime.tsx | TS環境初期化/実行例外を onError と fatalError 出力へ |
| app/terminal/repl.tsx | ランタイム fatalError の表示と onError ハンドラ接続 |
| app/terminal/exec.tsx | ランタイム onError ハンドラ接続 |
| app/terminal/page.tsx | ランタイム初期化時に onError を渡す・Sentryテスト用ボタン等を追加 |
| app/markdown/styledSyntaxHighlighter.tsx | FallbackPre を外部利用できるよう export |
| app/errorMessage.tsx | 共通エラー表示 + captureException + EventID表示/問い合わせリンクを追加 |
| app/error.tsx | ErrorMessage を使用するよう置換 |
| app/global-error.tsx | ErrorMessage を使用するグローバルエラー境界を追加 |
| app/(docs)/@chat/error.tsx | チャット領域のエラーページを ErrorMessage に置換 |
| app/api/chat/route.ts | AIストリーミング失敗時などに captureException 追加 |
| app/(docs)/@docs/[lang]/[pageId]/chatForm.tsx | fetch/parseエラーで captureException 追加 |
| app/actions/revalidateChat.ts | Server Action instrumentation(Sentry)追加 |
| app/actions/getRedirectFromChat.ts | Server Action instrumentation(Sentry)追加 |
| app/actions/deleteChat.ts | Server Action instrumentation(Sentry)追加 |
| app/actions/clearUserCache.ts | Server Action instrumentation(Sentry)追加 |
| app/about/license/ThirdPartyLicenses.tsx | ライセンス表示に FallbackPre を使用 |
| app/(docs)/layout.tsx | レイアウトのクラス調整(flex-1 追加) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try { | ||
| await initializeWorker(); | ||
| setReady(true); | ||
| } catch (error) { |
There was a problem hiding this comment.
initializeWorker() errors are now caught and only forwarded to onError, but doInit remains true and ready stays false, so calling init() again won’t re-trigger this effect (since setDoInit(true) is a no-op). Consider resetting doInit (or using an init-attempt counter) on failure so the runtime can be retried after transient errors.
| } catch (error) { | |
| } catch (error) { | |
| // Reject all pending promises from the failed initialization attempt | |
| const workerTerminatedError = new Error("Worker terminated"); | |
| pendingPromises.current.forEach((reject) => | |
| reject(workerTerminatedError) | |
| ); | |
| pendingPromises.current.clear(); | |
| workerRef.current?.terminate(); | |
| workerRef.current = null; | |
| workerApiRef.current = null; | |
| setReady(false); | |
| setDoInit(false); |
| <button | ||
| className="btn mt-4" | ||
| onClick={() => { | ||
| throw new Error("Sentry Test Error"); | ||
| }} | ||
| > | ||
| Sentry Test Error | ||
| </button> |
There was a problem hiding this comment.
Leaving a publicly visible button that intentionally throws ("Sentry Test Error") will generate noisy production errors and a confusing UX if this page is accessible outside local/dev use. Gate this behind NODE_ENV === "development"/a feature flag, or remove it before merging.
| captureException( | ||
| "AIからの応答にタイトルが含まれていませんでした", | ||
| { | ||
| extra: { | ||
| prompt, | ||
| fullText, | ||
| }, | ||
| } |
There was a problem hiding this comment.
captureException is called with extra: { prompt, fullText }, which likely includes user 질문/入力・ドキュメント断片・AI応答などの機微情報をそのまま外部のエラートラッカーに送ります。必要最小限の情報(例: 長さ/ハッシュ/一部マスク)に絞るか、明示的なデバッグフラグが有効なときだけ添付するようにしてください。
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.