Skip to content

Commit

Permalink
Disable max WebSocket message size validation in CDP proxy (#39833)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #39833

Reland of D49642047 which got reverted because of a CI infra error.

 ---

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: D49955025

fbshipit-source-id: aa5b8b55c885e26dd5b8170660603173cfe54de0
  • Loading branch information
motiz88 authored and facebook-github-bot committed Oct 6, 2023
1 parent 9252099 commit d0f750e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/dev-middleware/src/inspector-proxy/InspectorProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit d0f750e

Please sign in to comment.