-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot read property 'createErrorBoundary' of undefined #1112
Comments
Hi @duzliang , Could you confirm what error you are seeing? Also could you share you Bugsnag configuration code for both your JS and native layers. Feel free to email [email protected] if you don't want to share this information publicly. Thanks |
@johnkiely1 Thank you for viewing this issue: Both the Android and iOS configuration are set up step by step by the Docs Below is a simple Javascript code snippets:
when running the App, get the error:
|
I'm having the same problem here.
|
@duzliang
|
Move it out of the constructor also get the Error while open the
|
That does look like a bug, although one that would only have an impact when the debugger is attached. We'll look into whether this can be resolved in a future release. |
Is there a workaround for this? Being unable to attach a debugger makes getPlugin unusable. I'm using the Any recommendations on a fix? happy to help if I can get pointed in the right direction. |
Hey @adkenyon, we're looking into a fix for this notifier side. But, in the meantime you can guard against this by checking whether the class NoopErrorBoundary extends React.Component {
// define your Noop Error Boundary here
}
var ErrorBoundary;
if (typeof Bugsnag.getPlugin('react') === 'undefined') {
ErrorBoundary = NoopErrorBoundary;
} else {
ErrorBoundary = Bugsnag.getPlugin('react').createErrorBoundary(React);
}
// use the ErrorBoundary as normal When running without the debugger, Bugsnag will continue as normal with the Bugsnag error boundary. |
@xander-jones thank you for the workaround! |
Can you please reference this in your documentation until this is released? |
Fixed in v7.6.1 |
What i can do with code push if i need call asyncronus
const ErrorBoundary = Bugsnag.getPlugin('react').createErrorBoundary(React); and
Bugsnag is crashing and i have to add second block Bugsnag.start call
|
👋 Hey @interhub, you should start Bugsnag synchronously as soon as you can in your application to ensure that you're capturing all errors. This also means that you'll be able to create your
I appreciate that you're looking to get the CodePush label async on the launch of the application to set the If you're seeing Bugsnag crash though, please do let us know with a new issue on this repo with details of the crash & what's happening to cause the crash, and we'll take a look into this! :) |
@xander-jones I think this is related to an issue I think a lot of user's might have which is that while starting Bugsnag should be synchronous, CodePush users want to specify the Perhaps you could add some docs on how to "inject this codeBundleId value at bundle build time" OR specify in the docs https://docs.bugsnag.com/platforms/react-native/react-native/codepush/ that users should figure out how to do this themselves. Should I start a separate issue on this topic? I feel a few Bugsnag + CodePush users might have this issue as I've had this on multiple apps. |
Hey @henrymoulton, sure; it's difficult to specify an exact method that you should use as people use all sort of different build pipelines, and architect their apps in different ways. However, hopefully the following information will be hopefully be starting point for you? The concept here is to prep the source to have a First, in import Bugsnag from '@bugsnag/react-native';
const version = require("./package.json").version
const codePushLabel = require('./package.json').codePushLabel
Bugsnag.start({
codeBundleId: version + (codePushLabel == null ? '' : '_' + codePushLabel)
}); Now, in {
"name": "CodePushHarness",
"version": "1.0.0",
"codePushLabel": null,
// ... Next, we need to manipulate that This is where things diverge slightly depending on how you're building, but the following is a Node.js example I've put together, you can call this using It will:
const exec = require('child_process').exec
const fs = require('fs')
if (process.argv.length < 4) {
console.error("Missing input args. Usage: node codepush.js STAGE BINARYVERSION")
process.exit(1)
}
// Which stage are you deploying to?
const stage = process.argv[2]
console.debug("stage", stage)
// Which binary version is being targeted?
const binaryVersion = process.argv[3]
console.debug("binaryVersion", binaryVersion)
function injectLabelToPackage(label) {
const pjsonFilename = "./package.json"
const pjsonHandle = require(pjsonFilename)
pjsonHandle.codePushLabel = label
fs.writeFile(pjsonFilename, JSON.stringify(pjsonHandle, null, 2), function writeJSON(err) {
if (err) {
console.error(err)
process.exit()
} else {
return console.debug(`Set codePushLabel to ${label} in ${pjsonFilename}`)
}
})
}
function releaseCodepushUpdate() {
exec(`appcenter codepush release-react -d ${stage} -t ${binaryVersion} --output-dir build`, function(error, stdout, stderr){
console.log(stdout)
console.error(stderr)
})
}
exec("appcenter codepush deployment list --output json", function(error, stdout, stderr){
var codePushDeploymentList = JSON.parse(stdout)
var thisDeployment = codePushDeploymentList.find(obj => {
return obj.name == stage
})
console.debug("codePushDeploymentList", codePushDeploymentList)
console.debug("thisDeployment", thisDeployment)
if (thisDeployment !== undefined) {
var newLabel = null
if (thisDeployment.latestRelease.label !== undefined) {
// a CodePush label already exists for this stage
const currentLabel = thisDeployment.latestRelease.label
console.debug("currentLabel", currentLabel)
newLabel = "v" + (parseInt(currentLabel.substring(1, currentLabel.length)) + 1)
} else {
// no CodePush releases have been made yet for this stage, so this will be v1
newLabel = "v1"
}
console.debug("newLabel", newLabel)
injectLabelToPackage(newLabel)
// execute your CodePush release here.
releaseCodepushUpdate()
} else {
console.error(`Stage '${stage}' doesn't exist`)
process.exit(1)
}
}) In our docs we do mention that the |
Wow @xander-jones thanks so much for taking the time. This looks like a snazzy script that I could definitely adapt for our needs. |
Is there any information on why/when in
My configuration is:
|
Hi @neb-b - Is it possible that one of these conditions were met when you saw your production crash (e.g. if |
@luke-belton thanks for the info. Based on that, there must have been issues with the app reading the bugsnag api key, so I'm guessing it was undefined. |
@luke-belton upon further investigation, it doesn't appear that the app would have issues reading the api key so everything was passed in correctly. Our issue started from netlify network request errors, but our error logs were filled with |
Hi @neb-b, we're not aware of any other case in which the call to |
@yousif-bugsnag it appears there were a lot of network errors from netlify around that time. Could it be possible that the |
Hi @neb-b, failed network requests to
Here is the bugsnag-js/packages/core/client.js Lines 190 to 192 in 2005796
And the React plugin lives here: https://github.com/bugsnag/bugsnag-js/tree/master/packages/plugin-react |
Since nextjs cannot render on the build step, does this mean you can't use the ErrorBoundary there? https://github.com/bugsnag/bugsnag-js/blob/next/examples/js/nextjs/lib/bugsnag.js |
Following the Bugsnag Docs to config the project and run got this error from:
const ErrorBoundary = Bugsnag.getPlugin('react').createErrorBoundary(React);
The text was updated successfully, but these errors were encountered: