admin管理员组文章数量:1387467
I have a React project, and I'm using Bugsnag + BugsnagPluginReact to capture/report errors and implement an error boundary.
At the javascript entrypoint of our app, we start up Bugsnag:
import Bugsnag from "@bugsnag/js"
import BugsnagPluginReact from "@bugsnag/plugin-react"
Bugsnag.start({
...window.bugsnagSettings, // apiKey, releaseStage, appVersion, user
plugins: [new BugsnagPluginReact()],
})
Then, we have an ErrorBoundaryProvider component that we wrap the root of our react code with:
import Bugsnag from "@bugsnag/js"
import React from "react"
import ErrorFallback from "./ErrorFallback"
const ErrorBoundaryProvider = ({ children }) => {
const ErrorBoundaryWrapper = Bugsnag.getPlugin("react").createErrorBoundary(React)
return (
<ErrorBoundaryWrapper FallbackComponent={ErrorFallback}>
{children}
</ErrorBoundaryWrapper>
)
}
export default ErrorBoundaryProvider
My question is specifically around async code. For example, say that TestComponent
is a child of ErrorBoundaryProvider
:
const TestComponent = () => {
setTimeout(() => {
throw new Error("Did this error make it to the bugsnag dashboard?")
}, 1000)
return (
<div>Test</div>
)
}
Should I expect the error in the setTimeout
callback to show up on my bugsnag dashboard?
My understanding is that the react error boundary will NOT capture async errors like this. But I'm curious if Bugsnag will somehow pick it up anyway, as an unhandled exception.
The strange thing here is that we do see the error come through to the bugsnag dashboard, when we are in development mode, running the app locally on our machines. But, we don't see the error come through to the bugsnag dashboard when we have the app deployed to our staging/production environments.
版权声明:本文标题:reactjs - Should I expect my Bugsnag plugin to capture async errors? (using BugsnagPluginReact) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744545831a2611890.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论