Akylas / Akylas/nativescript-bugsnag

Unable to automatically handle promise rejections

Đang mở
#2 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
4
Fork
3
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### Which platform(s) does your issue occur on?
- iOS 11.4 emulator

### Please, provide the following version numbers that your issue occurs with:
- CLI: 5.3.4
- Cross-platform modules: 5.3.2
- Runtime(s): 5.3.1
- Plugin(s): nativescript-bugsnag 1.0.7

### Please, tell us how to recreate the issue in as much detail as possible.
I'm using Axios to make HTTP requests across my application, and would like to avoid adding `.catch` blocks to each one, so I'm trying to configure Bugsnag to automatically catch these promise rejections.

The README states:
> By default, unhandled promise rejections are reported in production.

but I haven't been able to get this to work.

Looking at the code, it seems `handleUncaughtErrors` is meant to register these global handlers, but this method isn't called as part of the Bugsnag initialization.

I added `bugsnag.handleUncaughtErrors()` to my consumer code after Bugsnag has been initialized (see below), but unhandled promise rejections are still not caught automatically. I have to use `bugsnag.notify()` each time I need to report an error. I would really appreciate your help figuring this out, so I don't have to litter my codebase with `bugsnag.notify()` calls :smile:

### Is there any code involved?
```
// Bugsnag initialization
const bugsnag = new Client()
bugsnag
.init(my-api-key)
.then(res => {
bugsnag.enableConsoleBreadcrumbs()
bugsnag.handleUncaughtErrors()
console.log('bugsnag did init', !!res)
})
.catch(err => {
console.log('bugsnag init failed', err)
})

[...]

// This unhandled Promise rejection (resulting in a 404) is not caught by Bugsnag
axios
.get('/api/invalid/url')
.then(response => {
console.log(response.data)
})
```

Instead, this is the only way I can get it to work:
```
axios
.get('/api/invalid/url')
.then(response => {
console.log(response.data)
})
.catch(error => {
bugsnag.notify(error)
})
```

P.S. Thank you for your work on this library!

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.