rollbar / rollbar.js

Error tracking and logging from Javascript to Rollbar

Home Page:https://docs.rollbar.com/docs/javascript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: t.headers.get is not a function. (In 't.headers.get("Content-Type")', 't.headers.get' is undefined)

dseeker opened this issue · comments

We're using an unusual setup with a hybrid iOS application running a compiled js file inside a native iOS app.
Seeing the user's report a lot of them are having an issue with the rollbar lib and I can't quite pinpoint why that's the case.
There's is probably some errors trying to get notified but it's failing after this line.

Would it be possible to add a check before executing headers.get()? I'm not sure how important setting the json type is, we could have some default value in case getting that header fails

on this line

metadata.response_content_type = resp.headers.get('Content-Type');

maybe something like this?

metadata.response_content_type = (resp.headers && typeof resp.headers.get === 'function') ? resp.headers.get('Content-Type') : '';

please let me know if there is a better way to debug this. I can't really reproduce it locally, I'm just seeing this in user's rollbar report

Yes, I think we can do something here.

@dseeker I hoped this could be accommodated while leaving network telemetry enabled. Instead I think it will be necessary to disable in your Rollbar config:

config.autoInstrument = { network: false }

This should solve the xhr/fetch related errors.

See https://docs.rollbar.com/docs/rollbarjs-telemetry for more details on telemetry support.