Avoid error-polyfill issues

Fix https://twitter.com/acemarke/status/1088131480197443584
This commit is contained in:
Zalmoxisus 2019-01-25 23:22:59 +02:00
parent 7c3b78d312
commit 22dc9f259c
2 changed files with 14 additions and 8 deletions

View File

@ -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": {

View File

@ -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.
*/
@ -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;
@ -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 {