Skip to content

Commit

Permalink
Avoid error-polyfill issues
Browse files Browse the repository at this point in the history
  • Loading branch information
zalmoxisus committed Jan 25, 2019
1 parent 7c3b78d commit 22dc9f2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/redux-devtools-instrument/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redux-devtools-instrument",
"version": "1.9.4",
"version": "1.9.5",
"description": "Redux DevTools instrumentation",
"main": "lib/instrument.js",
"scripts": {
Expand Down
20 changes: 13 additions & 7 deletions packages/redux-devtools-instrument/src/instrument.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ export const ActionTypes = {
PAUSE_RECORDING: 'PAUSE_RECORDING'
};

const isChrome = (
typeof window === 'object' && (
typeof window.chrome !== 'undefined' ||
typeof window.process !== 'undefined' &&
window.process.type === 'renderer'
));

const isChromeOrNode = (
isChrome || (typeof process !== 'undefined' && process.release.name === 'node')
);

/**
* Action creators to change the History state.
*/
Expand Down Expand Up @@ -46,7 +57,7 @@ export const ActionCreators = {
} else {
const error = Error();
let prevStackTraceLimit;
if (Error.captureStackTrace) {
if (Error.captureStackTrace && isChromeOrNode) { // avoid error-polyfill
if (Error.stackTraceLimit < traceLimit) {
prevStackTraceLimit = Error.stackTraceLimit;
Error.stackTraceLimit = traceLimit;
Expand Down Expand Up @@ -130,12 +141,7 @@ function computeWithTryCatch(reducer, action, state) {
nextState = reducer(state, action);
} catch (err) {
nextError = err.toString();
if (
typeof window === 'object' && (
typeof window.chrome !== 'undefined' ||
typeof window.process !== 'undefined' &&
window.process.type === 'renderer'
)) {
if (isChrome) {
// In Chrome, rethrowing provides better source map support
setTimeout(() => { throw err; });
} else {
Expand Down

0 comments on commit 22dc9f2

Please sign in to comment.