Skip to content

Commit

Permalink
cleanup[ReactDevToolsBindingsModel]: remove no longer required setTim…
Browse files Browse the repository at this point in the history
…eout (#132)
  • Loading branch information
hoxyq authored Oct 22, 2024
1 parent 117c96a commit ff343d8
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions front_end/models/react_native/ReactDevToolsBindingsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,7 @@ export class ReactDevToolsBindingsModel extends SDK.SDKModel.SDKModel {
}

const serializedMessage = JSON.stringify(message);
const sendMessageExpression = `${RUNTIME_GLOBAL}.sendMessage('${domainName}', '${serializedMessage}')`;

// As of today, all expressions which were scheduled via Runtime.evaluate method are not going through RuntimeScheduler
// This means that the task is not being placed on the Event Loop, and any transitively called Microtasks are not executed properly
// We are wrapping the expression in setTimeout to make sure that this code (and everything what is called by it) goes through the Event Loop implementation
// See T200616136 for more context
// TODO(hoxyq): remove setTimeout once Runtime.evaluate expressions are passed through React Native Runtime Scheduler
await runtimeModel.agent.invoke_evaluate({expression: `void setTimeout(() => ${sendMessageExpression}, 0)`});
await runtimeModel.agent.invoke_evaluate({expression: `${RUNTIME_GLOBAL}.sendMessage('${domainName}', '${serializedMessage}')`});
}

async enable(): Promise<void> {
Expand Down

0 comments on commit ff343d8

Please sign in to comment.