Skip to content
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

Recover from read-only window.console object #778

Merged
merged 2 commits into from
Aug 29, 2019

Conversation

waltjones
Copy link
Contributor

@waltjones waltjones commented Aug 29, 2019

Fixes: #751

In some environments, the console methods (e.g. log, debug, etc.) have been replaced with read-only properties. No known browsers do this by default, but it appears that other code running in the browser replaces or modifies window.console to use read-only properties. (See examples here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only)

In strict mode code environments, Rollbar will then fail with TypeError: setting getter-only property "debug". In non strict mode environments, Rollbar will silently fail to update the console methods.

This fix sets strict mode while updating the console methods. This ensures a consistent and predictable behavior across different code environments, and allows Rollbar to record a diagnostic message in cases where it might have silently failed before.

NOTE: This PR also includes a commit to reset telemetry hooks between tests. Otherwise, telemetry related tests can't work correctly.

@waltjones waltjones merged commit dcf46b1 into master Aug 29, 2019
mudetroit pushed a commit that referenced this pull request Mar 14, 2024
Recover from read-only window.console object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: setting getter-only property "debug"
1 participant