From 5d0c9443b820f13eea81b55b323ce9acc0993107 Mon Sep 17 00:00:00 2001 From: brymut Date: Thu, 4 Dec 2025 17:21:21 +0300 Subject: [PATCH 1/2] enhance: add dynamic import for stack trace decoding in error boundary. --- components/error-boundary.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/components/error-boundary.js b/components/error-boundary.js index 2f5bac160d..5c06d2800e 100644 --- a/components/error-boundary.js +++ b/components/error-boundary.js @@ -1,11 +1,11 @@ -import { Component } from 'react' +import { Component, useState } from 'react' import { StaticLayout } from './layout' import styles from '@/styles/error.module.css' import Image from 'react-bootstrap/Image' import copy from 'clipboard-copy' import Button from 'react-bootstrap/Button' import { useToast } from './toast' -import { decodeMinifiedStackTrace } from '@/lib/stacktrace' + class ErrorBoundary extends Component { constructor (props) { super(props) @@ -61,16 +61,25 @@ export default ErrorBoundary // This button is a functional component so we can use `useToast` hook, which // can't be easily done in a class component that already consumes a context const CopyErrorButton = ({ errorDetails }) => { + const [copying, setCopying] = useState(false) const toaster = useToast() const onClick = async () => { + setCopying(true) try { + const { decodeMinifiedStackTrace } = await import('@/lib/stacktrace') const decodedDetails = await decodeMinifiedStackTrace(errorDetails) await copy(decodedDetails) toaster?.success?.('copied') } catch (err) { console.error(err) toaster?.danger?.('failed to copy') + } finally { + setCopying(false) } } - return + return ( + + ) } From 621285b5fc96ce5ba6e8a3f93545e61666bccb79 Mon Sep 17 00:00:00 2001 From: brymut Date: Sat, 6 Dec 2025 14:12:14 +0300 Subject: [PATCH 2/2] rollback unnecessary copying state --- components/error-boundary.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/components/error-boundary.js b/components/error-boundary.js index 5c06d2800e..311c772512 100644 --- a/components/error-boundary.js +++ b/components/error-boundary.js @@ -1,4 +1,4 @@ -import { Component, useState } from 'react' +import { Component } from 'react' import { StaticLayout } from './layout' import styles from '@/styles/error.module.css' import Image from 'react-bootstrap/Image' @@ -61,10 +61,8 @@ export default ErrorBoundary // This button is a functional component so we can use `useToast` hook, which // can't be easily done in a class component that already consumes a context const CopyErrorButton = ({ errorDetails }) => { - const [copying, setCopying] = useState(false) const toaster = useToast() const onClick = async () => { - setCopying(true) try { const { decodeMinifiedStackTrace } = await import('@/lib/stacktrace') const decodedDetails = await decodeMinifiedStackTrace(errorDetails) @@ -73,13 +71,7 @@ const CopyErrorButton = ({ errorDetails }) => { } catch (err) { console.error(err) toaster?.danger?.('failed to copy') - } finally { - setCopying(false) } } - return ( - - ) + return }