From 2000acc6c6cbfd3942062b33c8285e155d404d4a Mon Sep 17 00:00:00 2001 From: Moti Zilberman Date: Wed, 4 Oct 2023 11:57:43 -0700 Subject: [PATCH] Disable max WebSocket message size validation in CDP proxy (#39809) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/39809 It's currently possible for RN to crash the dev server by sending down an exceptionally large CDP response/event. Instead of making assumptions on the protocol spoken over the proxy, let's assume clients on either side of the proxy can be trusted to be well behaved (and to degrade gracefully when a large message is encountered). Changelog: [General][Fixed] JS debugging: prevent dev server crash when a large CDP payload is returned from the device Reviewed By: huntie Differential Revision: D49642047 fbshipit-source-id: 07b134c9fa6aba7ce2208f71981d6d862281395f --- .../dev-middleware/src/inspector-proxy/InspectorProxy.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/dev-middleware/src/inspector-proxy/InspectorProxy.js b/packages/dev-middleware/src/inspector-proxy/InspectorProxy.js index 0cfb55a05ff..be4fe3e13a9 100644 --- a/packages/dev-middleware/src/inspector-proxy/InspectorProxy.js +++ b/packages/dev-middleware/src/inspector-proxy/InspectorProxy.js @@ -176,6 +176,9 @@ export default class InspectorProxy implements InspectorProxyQueries { const wss = new WS.Server({ noServer: true, perMessageDeflate: true, + // Don't crash on exceptionally large messages - assume the device is + // well-behaved and the debugger is prepared to handle large messages. + maxPayload: 0, }); // $FlowFixMe[value-as-type] wss.on('connection', async (socket: WS, req) => { @@ -228,6 +231,9 @@ export default class InspectorProxy implements InspectorProxyQueries { const wss = new WS.Server({ noServer: true, perMessageDeflate: false, + // Don't crash on exceptionally large messages - assume the debugger is + // well-behaved and the device is prepared to handle large messages. + maxPayload: 0, }); // $FlowFixMe[value-as-type] wss.on('connection', async (socket: WS, req) => {