Fix infinite console proxy bug in headless
Summary: Headless flipper is getting an infinite recursion problem after the console proxy was changed to an in-place method swap. This uses an in-place method swap in headless too, so they don't conflict with each other. Reviewed By: passy, priteshrnandgaonkar Differential Revision: D18007638 fbshipit-source-id: 62dce7fa94f4ce6b90da4f3c6ec6e8d9ed15fbe7
This commit is contained in:
committed by
Facebook Github Bot
parent
fdee0ef7b7
commit
ff5a1b72fd
@@ -216,17 +216,13 @@ async function startFlipper(userArguments: UserArguments) {
|
|||||||
|__| |_|_| _| _|___|_| v${global.__VERSION__}
|
|__| |_|_| _| _|___|_| v${global.__VERSION__}
|
||||||
|_| |_|
|
|_| |_|
|
||||||
`);
|
`);
|
||||||
|
|
||||||
// redirect all logging to stderr
|
// redirect all logging to stderr
|
||||||
const originalConsole = global.console;
|
const overriddenMethods = ['debug', 'info', 'log', 'warn', 'error'];
|
||||||
global.console = new Proxy(console, {
|
for (const method of overriddenMethods) {
|
||||||
get: function(_obj, prop) {
|
(global.console as {[key: string]: any})[method] =
|
||||||
return (...args: any[]) => {
|
method === 'error' || verbose ? global.console.error : () => {};
|
||||||
if (prop === 'error' || verbose) {
|
|
||||||
originalConsole.error(`[${String(prop)}] `, ...args);
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Polyfills
|
// Polyfills
|
||||||
global.WebSocket = require('ws'); // used for redux devtools
|
global.WebSocket = require('ws'); // used for redux devtools
|
||||||
|
|||||||
Reference in New Issue
Block a user