Skip to content

Commit 080fe3b

Browse files
committed
Remove supportsMultipleDebuggers capability from inspector proxy
1 parent 62ad508 commit 080fe3b

7 files changed

Lines changed: 15 additions & 210 deletions

File tree

‎packages/dev-middleware/src/__tests__/InspectorProxyCdpTransport-test.js‎

Lines changed: 1 addition & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {createDeviceMock} from './InspectorDeviceUtils';
2121
import {sendFromDebuggerToTarget} from './InspectorProtocolUtils';
2222
import {withAbortSignalForEachTest} from './ResourceUtils';
2323
import {withServerForEachTest} from './ServerUtils';
24-
import nullthrows from 'nullthrows';
2524
import until from 'wait-for-expect';
2625

2726
// WebSocket is unreliable when using fake timers.
@@ -155,136 +154,6 @@ describe.each(['HTTP', 'HTTPS'])(
155154
}
156155
});
157156

158-
test('multiple debuggers to the same page on the same device', async () => {
159-
let device, debugger1, debugger2;
160-
try {
161-
// Connect a device to the proxy.
162-
device = await createDeviceMock(
163-
`${serverRef.serverBaseWsUrl}/inspector/device?device=device1&name=foo&app=bar`,
164-
autoCleanup.signal,
165-
);
166-
// Capture a log of events so we can assert on their order later.
167-
const events: Array<
168-
| ConnectRequest
169-
| DisconnectRequest
170-
| {event: 'create-debugger-mock', name: string},
171-
> = [];
172-
device.disconnect.mockImplementation(message => {
173-
events.push(message);
174-
});
175-
device.connect.mockImplementation(message => {
176-
events.push(message);
177-
});
178-
// Set up the page.
179-
device.getPages.mockImplementation(() => [
180-
{
181-
app: 'bar-app',
182-
id: 'page1',
183-
title: 'bar-title',
184-
vm: 'bar-vm',
185-
},
186-
]);
187-
let pageList: Array<PageDescription> = [];
188-
await until(async () => {
189-
pageList = (await fetchJson(
190-
`${serverRef.serverBaseUrl}/json`,
191-
// $FlowFixMe[unclear-type]
192-
)) as any;
193-
expect(pageList).toHaveLength(1);
194-
});
195-
const [{webSocketDebuggerUrl}] = pageList;
196-
197-
// Connect the first debugger and send a message.
198-
events.push({event: 'create-debugger-mock', name: 'debugger1'});
199-
debugger1 = await createDebuggerMock(
200-
webSocketDebuggerUrl,
201-
autoCleanup.signal,
202-
);
203-
await sendFromDebuggerToTarget(debugger1, device, 'page1', {
204-
method: 'Runtime.enable',
205-
id: 0,
206-
});
207-
208-
// Connect the second debugger.
209-
events.push({event: 'create-debugger-mock', name: 'debugger2'});
210-
debugger2 = await createDebuggerMock(
211-
webSocketDebuggerUrl,
212-
autoCleanup.signal,
213-
);
214-
215-
// The first debugger gets disconnected. TODO: In the future, we should
216-
// amend the protocol to allow for multiple debuggers to connect at the
217-
// same time.
218-
await until(async () => {
219-
expect([
220-
// CLOSING
221-
3,
222-
// CLOSED
223-
4,
224-
]).toContain(debugger1.socket.readyState);
225-
});
226-
227-
// Send a message from the second debugger.
228-
await sendFromDebuggerToTarget(debugger2, device, 'page1', {
229-
method: 'Debugger.enable',
230-
id: 1,
231-
});
232-
233-
// Check the order of `connect` and `disconnect` events received by the
234-
// device. `create-debugger-mock` events are included for convenience.
235-
expect(events).toEqual([
236-
{
237-
event: 'create-debugger-mock',
238-
name: 'debugger1',
239-
},
240-
{
241-
event: 'connect',
242-
payload: {
243-
pageId: 'page1',
244-
sessionId: expect.any(String),
245-
},
246-
},
247-
{
248-
event: 'create-debugger-mock',
249-
name: 'debugger2',
250-
},
251-
{
252-
// NOTE: For debugger1
253-
event: 'disconnect',
254-
payload: {
255-
pageId: 'page1',
256-
sessionId: expect.any(String),
257-
},
258-
},
259-
{
260-
// NOTE: For debugger2
261-
event: 'connect',
262-
payload: {
263-
pageId: 'page1',
264-
sessionId: expect.any(String),
265-
},
266-
},
267-
]);
268-
// Verify that disconnect and second connect use different session IDs
269-
// (disconnect is for first debugger, connect is for second debugger)
270-
const disconnectEvent = nullthrows(
271-
events.find(e => e.event === 'disconnect'),
272-
);
273-
const connectEvents = events.filter(e => e.event === 'connect');
274-
expect(connectEvents).toHaveLength(2);
275-
expect(disconnectEvent.payload.sessionId).toBe(
276-
connectEvents[0].payload.sessionId,
277-
);
278-
expect(disconnectEvent?.payload.sessionId).not.toBe(
279-
connectEvents[1].payload.sessionId,
280-
);
281-
} finally {
282-
device?.close();
283-
debugger1?.close();
284-
debugger2?.close();
285-
}
286-
});
287-
288157
test('debugger connection to a nonexistent page is rejected', async () => {
289158
let device, debugger_;
290159
try {
@@ -665,23 +534,19 @@ describe.each(['HTTP', 'HTTPS'])(
665534
}
666535
});
667536

668-
test('page with supportsMultipleDebuggers allows concurrent debugger connections', async () => {
537+
test('allows concurrent debugger connections to a page', async () => {
669538
let device, debugger1, debugger2;
670539
try {
671540
device = await createDeviceMock(
672541
`${serverRef.serverBaseWsUrl}/inspector/device?device=device1&name=foo&app=bar`,
673542
autoCleanup.signal,
674543
);
675-
// Page with supportsMultipleDebuggers capability
676544
device.getPages.mockImplementation(() => [
677545
{
678546
app: 'bar-app',
679547
id: 'page1',
680548
title: 'bar-title',
681549
vm: 'bar-vm',
682-
capabilities: {
683-
supportsMultipleDebuggers: true,
684-
},
685550
},
686551
]);
687552
let pageList: Array<PageDescription> = [];

‎packages/dev-middleware/src/__tests__/InspectorProxyConcurrentSessions-test.js‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('inspector proxy concurrent sessions', () => {
2626
const autoCleanup = withAbortSignalForEachTest();
2727

2828
describe('enableStandaloneFuseboxShell experiment disabled', () => {
29-
test('page reporting supportsMultipleDebuggers:true is treated as false', async () => {
29+
test('connecting a second debugger disconnects the first', async () => {
3030
// Create a server with the experiment disabled
3131
const {server} = await createServer({
3232
logger: undefined,
@@ -39,7 +39,6 @@ describe('inspector proxy concurrent sessions', () => {
3939

4040
let device, debugger1, debugger2;
4141
try {
42-
// Connect a device with a page that explicitly reports supportsMultipleDebuggers: true
4342
device = await createDeviceMock(
4443
`${serverBaseWsUrl}/inspector/device?device=device1&name=foo&app=bar`,
4544
autoCleanup.signal,
@@ -50,9 +49,6 @@ describe('inspector proxy concurrent sessions', () => {
5049
app: 'bar-app',
5150
title: 'bar-title',
5251
vm: 'bar-vm',
53-
capabilities: {
54-
supportsMultipleDebuggers: true,
55-
},
5652
},
5753
]);
5854

@@ -66,11 +62,6 @@ describe('inspector proxy concurrent sessions', () => {
6662
expect(pageList).toHaveLength(1);
6763
});
6864

69-
// Verify the capability is reported as false in the page list
70-
expect(
71-
pageList[0].reactNative?.capabilities?.supportsMultipleDebuggers,
72-
).toBe(false);
73-
7465
const webSocketDebuggerUrl = pageList[0].webSocketDebuggerUrl;
7566

7667
// Connect first debugger

‎packages/dev-middleware/src/__tests__/InspectorProxyDeviceHandoff-test.js‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ describe('inspector-proxy device socket handoff', () => {
151151
test('device ID collision with multiple debuggers connected restores all connections', async () => {
152152
let device1, device2, debugger1, debugger2, webSocketDebuggerUrl;
153153
try {
154-
// Connect device with a page that supports multiple debuggers
155154
({
156155
device: device1,
157156
pageList: [{webSocketDebuggerUrl}],
@@ -161,9 +160,6 @@ describe('inspector-proxy device socket handoff', () => {
161160
{
162161
...PAGE_DEFAULTS,
163162
vm: 'bar-vm',
164-
capabilities: {
165-
supportsMultipleDebuggers: true,
166-
},
167163
},
168164
],
169165
));
@@ -192,9 +188,6 @@ describe('inspector-proxy device socket handoff', () => {
192188
{
193189
...PAGE_DEFAULTS,
194190
vm: 'bar-vm-updated',
195-
capabilities: {
196-
supportsMultipleDebuggers: true,
197-
},
198191
},
199192
],
200193
));

‎packages/dev-middleware/src/__tests__/InspectorProxyHttpApi-test.js‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,7 @@ describe('inspector proxy HTTP API', () => {
199199
devtoolsFrontendUrl: expect.any(String),
200200
id: 'device1-page1',
201201
reactNative: {
202-
capabilities: {
203-
supportsMultipleDebuggers: false,
204-
},
202+
capabilities: {},
205203
logicalDeviceId: 'device1',
206204
},
207205
title: 'bar-title',
@@ -216,9 +214,7 @@ describe('inspector proxy HTTP API', () => {
216214
devtoolsFrontendUrl: expect.any(String),
217215
id: 'device2-page1',
218216
reactNative: {
219-
capabilities: {
220-
supportsMultipleDebuggers: false,
221-
},
217+
capabilities: {},
222218
logicalDeviceId: 'device2',
223219
},
224220
title: 'bar-title',

‎packages/dev-middleware/src/inspector-proxy/Device.js‎

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,7 @@ export default class Device {
369369
// Clear any commands we were waiting on.
370370
this.#deviceEventReporter?.logDisconnection('debugger');
371371

372-
// Check if this specific page supports multiple debuggers.
373-
// If not (legacy mode), disconnect existing debuggers for THIS PAGE only
374-
// before connecting the new one.
375-
if (!this.#pageHasCapability(page, 'supportsMultipleDebuggers')) {
372+
if (!this.#experiments.enableStandaloneFuseboxShell) {
376373
for (const [sid, conn] of this.#debuggerConnections) {
377374
if (conn.pageId === pageId) {
378375
this.#terminateDebuggerConnection(
@@ -554,22 +551,11 @@ export default class Device {
554551
#handleMessageFromDevice(message: MessageFromDevice) {
555552
if (message.event === 'getPages') {
556553
// Preserve ordering - getPages guarantees addition order.
557-
const shouldDisableMultipleDebuggers =
558-
!this.#experiments.enableStandaloneFuseboxShell;
559554
this.#pages = new Map(
560-
message.payload.map(({capabilities: rawCapabilities, ...page}) => {
561-
const capabilities: TargetCapabilityFlags =
562-
shouldDisableMultipleDebuggers
563-
? {...(rawCapabilities ?? {}), supportsMultipleDebuggers: false}
564-
: (rawCapabilities ?? {});
565-
return [
566-
page.id,
567-
{
568-
...page,
569-
capabilities,
570-
},
571-
];
572-
}),
555+
message.payload.map(({capabilities, ...page}) => [
556+
page.id,
557+
{...page, capabilities: capabilities ?? {}},
558+
]),
573559
);
574560

575561
if (message.payload.length !== this.#pages.size) {

‎packages/dev-middleware/src/inspector-proxy/__docs__/README.md‎

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,10 @@ interface Page {
127127
capabilities?: {
128128
nativePageReloads?: boolean; // Target keeps the socket open across reloads
129129
nativeSourceCodeFetching?: boolean; // Target supports Network.loadNetworkResource
130-
supportsMultipleDebuggers?: boolean; // Supports concurrent debugger sessions
131130
};
132131
}
133132
```
134133

135-
**Note**: The value of `supportsMultipleDebuggers` SHOULD be consistent across
136-
all pages for a given device.
137-
138134
### Connection Lifecycle
139135

140136
**Device Registration:**
@@ -186,29 +182,17 @@ its page, if `sessionId` is omitted).
186182

187183
#### Multi-Debugger Support
188184

189-
Multiple debuggers can connect simultaneously to the same page when **both** the
190-
proxy and device support session multiplexing:
191-
192-
1. **Session IDs**: The proxy assigns a unique, non-empty `sessionId` to each
193-
debugger connection. All messages include this `sessionId` for routing. This
194-
SHOULD be a UUID or other suitably unique and ephemeral identifier.
195-
196-
2. **Capability Detection**: Devices report `supportsMultipleDebuggers: true` in
197-
their page capabilities to indicate session support.
198-
199-
3. **Backwards Compatibility**: Legacy devices ignore `sessionId` fields in
200-
incoming messages and don't include them in responses.
185+
Multiple debuggers can connect simultaneously to the same page. The proxy
186+
assigns a unique, non-empty `sessionId` to each debugger connection. All
187+
messages include this `sessionId` for routing. This SHOULD be a UUID or other
188+
suitably unique and ephemeral identifier.
201189

202190
#### Connection Rules
203191

204-
1. **Session-Capable Device**: Multiple debuggers can connect to the same page
192+
1. **Concurrent Sessions**: Multiple debuggers can connect to the same page
205193
simultaneously. Each connection has an independent session.
206194

207-
2. **Legacy Device (no `supportsMultipleDebuggers`)**: New debugger connections
208-
to an already-connected page disconnect the existing debugger. The proxy MUST
209-
NOT allow multiple debuggers to connect to the same page.
210-
211-
3. **Device Reconnection**: If a device reconnects with the same `device` ID
195+
2. **Device Reconnection**: If a device reconnects with the same `device` ID
212196
while debugger connections to the same logical device are open in the proxy,
213197
the proxy may attempt to preserve active debugger sessions by forwarding them
214198
to the new device.

‎packages/dev-middleware/src/inspector-proxy/types.js‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,6 @@ export type TargetCapabilityFlags = Readonly<{
3030
* In the proxy, this disables source fetching emulation and host rewrites.
3131
*/
3232
nativeSourceCodeFetching?: boolean,
33-
34-
/**
35-
* The target supports multiple concurrent debugger connections.
36-
*
37-
* When true, the proxy allows multiple debuggers to connect to the same
38-
* page simultaneously, each identified by a unique session ID.
39-
* When false (default/legacy), connecting a new debugger disconnects
40-
* any existing debugger connection to that page.
41-
*/
42-
supportsMultipleDebuggers?: boolean,
4333
}>;
4434

4535
// Page information received from the device. New page is created for

0 commit comments

Comments
 (0)