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",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Attach to Flipper Server",
|
||||
"type": "node",
|
||||
"request": "attach",
|
||||
"port": 9229,
|
||||
"sourceMaps": true,
|
||||
"skipFiles": ["<node_internals>/**"]
|
||||
},
|
||||
{
|
||||
"name": "Attach to Running Renderer",
|
||||
"type": "chrome",
|
||||
@@ -21,10 +29,7 @@
|
||||
"request": "launch",
|
||||
"name": "Launch Current Jest Suite",
|
||||
"program": "${workspaceFolder}/node_modules/.bin/jest",
|
||||
"args": [
|
||||
"--runInBand",
|
||||
"${relativeFile}"
|
||||
],
|
||||
"args": ["--runInBand", "${relativeFile}"],
|
||||
"env": {
|
||||
"TZ": "Pacific/Pohnpei"
|
||||
}
|
||||
@@ -34,27 +39,19 @@
|
||||
"cwd": "${fileDirname}",
|
||||
"request": "launch",
|
||||
"name": "Launch Current Script",
|
||||
"args": [
|
||||
"${file}"
|
||||
],
|
||||
"args": ["${file}"],
|
||||
"env": {
|
||||
"TS_NODE_FILES": "true"
|
||||
},
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart",
|
||||
"runtimeArgs": [
|
||||
"--require",
|
||||
"ts-node/register"
|
||||
]
|
||||
"runtimeArgs": ["--require", "ts-node/register"]
|
||||
}
|
||||
],
|
||||
"compounds": [
|
||||
{
|
||||
"name": "Attach to All",
|
||||
"configurations": [
|
||||
"Attach to Running Main",
|
||||
"Attach to Running Renderer"
|
||||
]
|
||||
"configurations": ["Attach to Running Main", "Attach to Running Renderer"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -37,7 +37,12 @@ export function startSocketServer(
|
||||
.catch((error: any) => {
|
||||
if (connected) {
|
||||
// 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';
|
||||
|
||||
const CONNECTION_TIMEOUT = 30 * 1000;
|
||||
const EXEC_TIMOUT = 10 * 1000;
|
||||
const EXEC_TIMOUT = 30 * 10 * 1000;
|
||||
|
||||
export function createFlipperServer(): Promise<FlipperServer> {
|
||||
// TODO: polish this all!
|
||||
@@ -90,8 +90,8 @@ export function createFlipperServer(): Promise<FlipperServer> {
|
||||
close() {},
|
||||
exec(command, ...args): any {
|
||||
if (connected) {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
const id = ++requestId;
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
console.debug('exec >>>', id, command, args);
|
||||
|
||||
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.',
|
||||
type: 'boolean',
|
||||
},
|
||||
build: {
|
||||
describe:
|
||||
'Build the server without watching for changing or starting the service',
|
||||
type: 'boolean',
|
||||
},
|
||||
})
|
||||
.version('DEV')
|
||||
.help()
|
||||
@@ -113,13 +118,17 @@ let proc: child.ChildProcess | undefined;
|
||||
|
||||
function launchServer() {
|
||||
console.log('⚙️ Launching flipper-server...');
|
||||
proc = child.spawn('node', [`../flipper-server/server.js`], {
|
||||
proc = child.spawn(
|
||||
'node',
|
||||
['--inspect=9229', `../flipper-server/server.js`],
|
||||
{
|
||||
cwd: serverDir,
|
||||
env: {
|
||||
...process.env,
|
||||
},
|
||||
stdio: 'inherit',
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
async function restartServer() {
|
||||
@@ -173,6 +182,10 @@ async function startWatchChanges() {
|
||||
}
|
||||
|
||||
(async () => {
|
||||
if (argv['build']) {
|
||||
await compileServerMain();
|
||||
} else {
|
||||
await startWatchChanges();
|
||||
restartServer();
|
||||
restartServer(); // builds and starts
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user