Skip to content

Commit

Permalink
refactor[ReactDevToolsBindingsModel]: dont send messages when executi…
Browse files Browse the repository at this point in the history
…on context is destroyed (#114)

* fix[ReactDevTools]: wrap sendMessage expressions in setTimeout

* refactor[ReactDevToolsBindingsModel]: dont send messages when execution context is destroyed
  • Loading branch information
hoxyq authored Sep 9, 2024
1 parent e32908e commit 50a4d4f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions front_end/models/react_native/ReactDevToolsBindingsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ export class ReactDevToolsBindingsModel extends SDK.SDKModel.SDKModel {
}

async sendMessage(domainName: DomainName, message: JSONValue): Promise<void> {
// If Execution Context is destroyed, do not attempt to send a message (evaluate anything)
// This could happen when we destroy Bridge from ReactDevToolsModel, which attempts to send `shutdown` event
// We still need to call `bridge.shutdown()` in order to unsubscribe all listeners on the Frontend (this) side
if (!this.fuseboxDispatcherIsInitialized) {
return;
}

const runtimeModel = this.target().model(SDK.RuntimeModel.RuntimeModel);
if (!runtimeModel) {
throw new Error(`Failed to send message from ReactDevToolsBindingsModel for domain ${domainName}: runtime model is not available`);
Expand Down

0 comments on commit 50a4d4f

Please sign in to comment.