Skip to content

Commit 28661b3

Browse files
committed
fix(dev-server): validate open-stack-frame request body; test: reduce E2E CI load
- Reject open-stack-frame bodies where file is not a string, contains NUL bytes, or lineNumber is not numeric, and declare the plugin's @fastify/sensible dependency. - Run the E2E dev servers with --platform ios: the suite exercises a single platform and compiling both doubled the load on shared CI runners, pushing an unrelated tester-app bundle test past its timeout. - Stop test servers with SIGKILL — a SIGTERM caught mid-compilation left an orphan holding the port for later runs.
1 parent 0c1adcd commit 28661b3

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

packages/dev-server/src/plugins/devtools/devtoolsPlugin.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ async function devtoolsPlugin(
4646
const { file, lineNumber } = parseRequestBody<OpenStackFrameRequestBody>(
4747
request.body
4848
);
49+
if (
50+
typeof file !== 'string' ||
51+
file.includes('\0') ||
52+
!Number.isFinite(Number(lineNumber))
53+
) {
54+
reply.badRequest('Invalid open-stack-frame request body');
55+
return;
56+
}
4957
const filepath = delegate.devTools?.resolveProjectPath(file) ?? file;
5058

5159
// launch-editor silently ignores files that don't exist, so surface
@@ -88,5 +96,5 @@ async function devtoolsPlugin(
8896

8997
export default fastifyPlugin(devtoolsPlugin, {
9098
name: 'devtools-plugin',
91-
dependencies: ['wss-plugin'],
99+
dependencies: ['@fastify/sensible', 'wss-plugin'],
92100
});

tests/integration/e2e/symbolication.test.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,17 @@ let remoteFrame: StackFrame;
5454
function startServer(configFile: string, port: number): ChildProcess {
5555
const child = spawn(
5656
reactNativeBin,
57-
['webpack-start', '--config', configFile, '--port', String(port)],
57+
[
58+
'webpack-start',
59+
'--config',
60+
configFile,
61+
'--port',
62+
String(port),
63+
// Compile a single platform: the suite only exercises one, and the
64+
// extra compilation is wasted load on shared CI runners.
65+
'--platform',
66+
PLATFORM,
67+
],
5868
{
5969
cwd: appDir,
6070
env: {
@@ -74,7 +84,10 @@ function startServer(configFile: string, port: number): ChildProcess {
7484
function stopServer(child: ChildProcess | undefined) {
7585
if (child?.pid) {
7686
try {
77-
process.kill(-child.pid, 'SIGTERM');
87+
// SIGKILL the whole process group: these are throwaway test servers,
88+
// and a SIGTERM caught mid-compilation has been observed to leave an
89+
// orphan behind that breaks subsequent runs.
90+
process.kill(-child.pid, 'SIGKILL');
7891
} catch {
7992
// Already gone.
8093
}

0 commit comments

Comments
 (0)