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__}
|
||||
|_| |_|
|
||||
`);
|
||||
|
||||
// redirect all logging to stderr
|
||||
const originalConsole = global.console;
|
||||
global.console = new Proxy(console, {
|
||||
get: function(_obj, prop) {
|
||||
return (...args: any[]) => {
|
||||
if (prop === 'error' || verbose) {
|
||||
originalConsole.error(`[${String(prop)}] `, ...args);
|
||||
const overriddenMethods = ['debug', 'info', 'log', 'warn', 'error'];
|
||||
for (const method of overriddenMethods) {
|
||||
(global.console as {[key: string]: any})[method] =
|
||||
method === 'error' || verbose ? global.console.error : () => {};
|
||||
}
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// Polyfills
|
||||
global.WebSocket = require('ws'); // used for redux devtools
|
||||
|
||||
Reference in New Issue
Block a user