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

cleanup[ReactDevToolsBindingsModel]: remove no longer required setTimeout #132

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading