Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: devtools cannot be closed correctly #25510

Merged
merged 10 commits into from
Jun 13, 2023
3 changes: 3 additions & 0 deletions packages/react-devtools-shared/src/__tests__/bridge-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ describe('Bridge', () => {
send: jest.fn(),
};
const bridge = new Bridge(wall);
const shutdownCallback = jest.fn();
bridge.addListener('shutdown', shutdownCallback);

// Check that we're wired up correctly.
bridge.send('reloadAppForProfiling');
Expand All @@ -36,6 +38,7 @@ describe('Bridge', () => {
expect(wall.send).toHaveBeenCalledWith('update', '1');
expect(wall.send).toHaveBeenCalledWith('update', '2');
expect(wall.send).toHaveBeenCalledWith('shutdown');
expect(shutdownCallback).toHaveBeenCalledTimes(1);

// Verify that the Bridge doesn't send messages after shutdown.
jest.spyOn(console, 'warn').mockImplementation(() => {});
Expand Down
1 change: 1 addition & 0 deletions packages/react-devtools-shared/src/bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ class Bridge<
}

// Queue the shutdown outgoing message for subscribers.
this.emit('shutdown');
this.send('shutdown');

// Mark this bridge as destroyed, i.e. disable its public API.
Expand Down