rollbar / rollbar.js

Error tracking and logging from Javascript to Rollbar
https://docs.rollbar.com/docs/javascript
MIT License
571 stars 213 forks source link

Polyfill the fetch Headers object if needed #1014

Closed waltjones closed 2 years ago

waltjones commented 2 years ago

Description of the change

The network telemetry code paths rely on the standard Headers object for case insensitive handling of request headers. While Headers is part of the fetch API standard, and has been included in browser implementations since fetch was first introduced, there are some fetch polyfills that don't implement Headers.

This PR uses a minimal polyfill when Headers is undefined. Though referred to here as a "polyfill", it is not added to the window object and does not replace or export any global functionality. It is only used internally by Rollbar.js.

Notes:

Type of change

Related issues

Fixes: https://github.com/rollbar/rollbar.js/issues/1011

Development

Code review