From 7d6acd01da0191206acb76afb113666c1a078387 Mon Sep 17 00:00:00 2001 From: Aylan Brown Date: Tue, 3 Sep 2019 10:07:47 +0800 Subject: [PATCH 1/3] process.env is undefined --- src/browser.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/browser.js b/src/browser.js index ac3f7e13..bd860cb7 100644 --- a/src/browser.js +++ b/src/browser.js @@ -213,7 +213,8 @@ function load() { } // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (!r && typeof process !== 'undefined' && 'env' in process) { + // process.env is undefined in sometimes, and it will throw a exception + if (!r && typeof process !== 'undefined' && 'env' in process && process.env !== undefined) { r = process.env.DEBUG; } From 6df7bd3a34758f8290ac8a98c3fff2d942cce216 Mon Sep 17 00:00:00 2001 From: Aylan Brown Date: Tue, 3 Sep 2019 16:58:27 +0800 Subject: [PATCH 2/3] only process.env, remove useless code --- src/browser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser.js b/src/browser.js index bd860cb7..987d4850 100644 --- a/src/browser.js +++ b/src/browser.js @@ -214,7 +214,7 @@ function load() { // If debug isn't set in LS, and we're in Electron, try to load $DEBUG // process.env is undefined in sometimes, and it will throw a exception - if (!r && typeof process !== 'undefined' && 'env' in process && process.env !== undefined) { + if (!r && typeof process !== 'undefined' && process.env) { r = process.env.DEBUG; } From 60e443b7d61abf538136a2e7521bed0c58a251db Mon Sep 17 00:00:00 2001 From: Aylan Brown Date: Wed, 4 Sep 2019 11:40:09 +0800 Subject: [PATCH 3/3] Browser throw `process.env is undefined` --- src/browser.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/browser.js b/src/browser.js index 987d4850..f1c85d11 100644 --- a/src/browser.js +++ b/src/browser.js @@ -214,9 +214,14 @@ function load() { // If debug isn't set in LS, and we're in Electron, try to load $DEBUG // process.env is undefined in sometimes, and it will throw a exception - if (!r && typeof process !== 'undefined' && process.env) { - r = process.env.DEBUG; + try { + if (!r && typeof process !== 'undefined' && 'env' in process) { + r = process.env.DEBUG; + } + } catch(error) { + // Browser throw `process.env is undefined` } + return r; }