Make flipper server debuggable
Summary: This diffs adds debugging support to flipper server, by adding VSCode config for it Reviewed By: timur-valiev, aigoncharov Differential Revision: D32982874 fbshipit-source-id: 8e187ad05a05566a598db04b97e8b08e3de7e835
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ae56f2b62f
commit
73c6e8ee05
27
desktop/.vscode/launch.json
vendored
27
desktop/.vscode/launch.json
vendored
@@ -1,6 +1,14 @@
|
|||||||
{
|
{
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Attach to Flipper Server",
|
||||||
|
"type": "node",
|
||||||
|
"request": "attach",
|
||||||
|
"port": 9229,
|
||||||
|
"sourceMaps": true,
|
||||||
|
"skipFiles": ["<node_internals>/**"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Attach to Running Renderer",
|
"name": "Attach to Running Renderer",
|
||||||
"type": "chrome",
|
"type": "chrome",
|
||||||
@@ -21,10 +29,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "Launch Current Jest Suite",
|
"name": "Launch Current Jest Suite",
|
||||||
"program": "${workspaceFolder}/node_modules/.bin/jest",
|
"program": "${workspaceFolder}/node_modules/.bin/jest",
|
||||||
"args": [
|
"args": ["--runInBand", "${relativeFile}"],
|
||||||
"--runInBand",
|
|
||||||
"${relativeFile}"
|
|
||||||
],
|
|
||||||
"env": {
|
"env": {
|
||||||
"TZ": "Pacific/Pohnpei"
|
"TZ": "Pacific/Pohnpei"
|
||||||
}
|
}
|
||||||
@@ -34,27 +39,19 @@
|
|||||||
"cwd": "${fileDirname}",
|
"cwd": "${fileDirname}",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "Launch Current Script",
|
"name": "Launch Current Script",
|
||||||
"args": [
|
"args": ["${file}"],
|
||||||
"${file}"
|
|
||||||
],
|
|
||||||
"env": {
|
"env": {
|
||||||
"TS_NODE_FILES": "true"
|
"TS_NODE_FILES": "true"
|
||||||
},
|
},
|
||||||
"protocol": "inspector",
|
"protocol": "inspector",
|
||||||
"internalConsoleOptions": "openOnSessionStart",
|
"internalConsoleOptions": "openOnSessionStart",
|
||||||
"runtimeArgs": [
|
"runtimeArgs": ["--require", "ts-node/register"]
|
||||||
"--require",
|
|
||||||
"ts-node/register"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"compounds": [
|
"compounds": [
|
||||||
{
|
{
|
||||||
"name": "Attach to All",
|
"name": "Attach to All",
|
||||||
"configurations": [
|
"configurations": ["Attach to Running Main", "Attach to Running Renderer"]
|
||||||
"Attach to Running Main",
|
|
||||||
"Attach to Running Renderer"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,12 @@ export function startSocketServer(
|
|||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
if (connected) {
|
if (connected) {
|
||||||
// TODO: Serialize error
|
// TODO: Serialize error
|
||||||
client.emit('exec-response-error', id, error.toString());
|
// TODO: log if verbose console.warn('Failed to handle response', error);
|
||||||
|
client.emit(
|
||||||
|
'exec-response-error',
|
||||||
|
id,
|
||||||
|
error.toString() + (error.stack ? `\n${error.stack}` : ''),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {FlipperServer} from 'flipper-common';
|
|||||||
import {io, Socket} from 'socket.io-client';
|
import {io, Socket} from 'socket.io-client';
|
||||||
|
|
||||||
const CONNECTION_TIMEOUT = 30 * 1000;
|
const CONNECTION_TIMEOUT = 30 * 1000;
|
||||||
const EXEC_TIMOUT = 10 * 1000;
|
const EXEC_TIMOUT = 30 * 10 * 1000;
|
||||||
|
|
||||||
export function createFlipperServer(): Promise<FlipperServer> {
|
export function createFlipperServer(): Promise<FlipperServer> {
|
||||||
// TODO: polish this all!
|
// TODO: polish this all!
|
||||||
@@ -90,8 +90,8 @@ export function createFlipperServer(): Promise<FlipperServer> {
|
|||||||
close() {},
|
close() {},
|
||||||
exec(command, ...args): any {
|
exec(command, ...args): any {
|
||||||
if (connected) {
|
if (connected) {
|
||||||
|
const id = ++requestId;
|
||||||
return new Promise<any>((resolve, reject) => {
|
return new Promise<any>((resolve, reject) => {
|
||||||
const id = ++requestId;
|
|
||||||
console.debug('exec >>>', id, command, args);
|
console.debug('exec >>>', id, command, args);
|
||||||
|
|
||||||
pendingRequests.set(id, {
|
pendingRequests.set(id, {
|
||||||
|
|||||||
@@ -54,6 +54,11 @@ const argv = yargs
|
|||||||
'[FB-internal only] Will force using public sources only, to be able to iterate quickly on the public version. If sources are checked out from GitHub this is already the default. Setting env var "FLIPPER_FORCE_PUBLIC_BUILD" is equivalent.',
|
'[FB-internal only] Will force using public sources only, to be able to iterate quickly on the public version. If sources are checked out from GitHub this is already the default. Setting env var "FLIPPER_FORCE_PUBLIC_BUILD" is equivalent.',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
},
|
},
|
||||||
|
build: {
|
||||||
|
describe:
|
||||||
|
'Build the server without watching for changing or starting the service',
|
||||||
|
type: 'boolean',
|
||||||
|
},
|
||||||
})
|
})
|
||||||
.version('DEV')
|
.version('DEV')
|
||||||
.help()
|
.help()
|
||||||
@@ -113,13 +118,17 @@ let proc: child.ChildProcess | undefined;
|
|||||||
|
|
||||||
function launchServer() {
|
function launchServer() {
|
||||||
console.log('⚙️ Launching flipper-server...');
|
console.log('⚙️ Launching flipper-server...');
|
||||||
proc = child.spawn('node', [`../flipper-server/server.js`], {
|
proc = child.spawn(
|
||||||
cwd: serverDir,
|
'node',
|
||||||
env: {
|
['--inspect=9229', `../flipper-server/server.js`],
|
||||||
...process.env,
|
{
|
||||||
|
cwd: serverDir,
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
},
|
||||||
|
stdio: 'inherit',
|
||||||
},
|
},
|
||||||
stdio: 'inherit',
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function restartServer() {
|
async function restartServer() {
|
||||||
@@ -173,6 +182,10 @@ async function startWatchChanges() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
await startWatchChanges();
|
if (argv['build']) {
|
||||||
restartServer();
|
await compileServerMain();
|
||||||
|
} else {
|
||||||
|
await startWatchChanges();
|
||||||
|
restartServer(); // builds and starts
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user