After upgrading my debug dependency from 2.3.0 to 2.3.2 nothing works again.
My index.html runs the following code before running any JS library:
<script>
localStorage.setItem('debug', '*');
</script>
<!-- Load JS libs now -->
It has worked with any previous version of the debug library. Now it doesn't and nothing it logged.
In fact, once the the JS library (which includes the debug dependency) is loaded, localStorage.getItem('debug') returns false.
This is critical.
My JS app uses browserify. However I've checked that lib/browser.js is loaded (as it must be), so that's not the problem.
The issue is here, in lib/browser.js (I've added some console warns):
function load() {
var r;
try {
r = exports.storage.debug;
console.warn('1 - r:%o', r);
} catch(e) {}
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
if ('env' in (typeof process === 'undefined' ? {} : process)) {
r = process.env.DEBUG;
console.warn('2 - r:%o', r);
}
return r;
}
And this is the output:
browser.js:152 1 - r:"* -engine* -socket* *ERROR* *WARN*"
browser.js:158 2 - r:undefined
This is, initially it reads the debug key from localStorage. And after that, it checks whether a process global (or local scope) variable does exist, and in that case it "assumes" that we are in Electron.
I'm using envify which INDEED declares process as a local variable in order to allow the JS app in the browser check process.env stuff. That does NOT mean that we are in Electron.
Please, fix that. If Electron checks are needed do it, but don't break other valid usages of process.
Any word on getting this fix into a new version ?
Guys, this is a terrible issue for which there is already a fix in master. Please, publish a new NPM version of debug module.
2.3.3 published
Most helpful comment
2.3.3 published