-
Notifications
You must be signed in to change notification settings - Fork 24.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix race condition in RCTLoggingTests integration tests #34858
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Summary: Changelog: [iOS][Fixed] - Fix race condition in RCTLoggingTests integration tests RCTLoggingTests work in the following way: * Put a custom hook on logging (logging function) to intercept log messages * Send several log messages via JS and see whether they hit the hook as expected The problem with this approach was that there may be unexpected log messages, which squeeze inbetween the points of time when the hook was set and when the first message was sent. There was a (now 6 years old!!!) fix to mitigate this problem, which was adding a lead pause of 2s to "make sure" that all the other possible log messages had been sent: facebook#10568 That didn't actually guarantee fixing the problem in general, just partially mitigating it, as the race condition conceptually still remained there. Here I take a different approach, which should guarantee that we skip all the rogue JS messages before we start sending and reading them on our own: * Install the hook * Log a "marker" message * Pump the log until the marker appears - at this point we know that the hook has been definitely installed Differential Revision: D40043442 fbshipit-source-id: 396501cc48eafc9a41f4c5eb4b7d2a5019b0b212
This pull request was exported from Phabricator. Differential Revision: D40043442 |
Base commit: 793ebf6 |
Base commit: 793ebf6 |
This pull request was successfully merged by Ruslan Shestopalyuk in 540ae39. When will my fix make it into a release? | Upcoming Releases |
The failed TestDocker test looks to be due to infra issues, not related to the change:
|
OlimpiaZurek
pushed a commit
to OlimpiaZurek/react-native
that referenced
this pull request
May 22, 2023
Summary: Pull Request resolved: facebook#34858 Changelog: [iOS][Fixed] - Fix race condition in RCTLoggingTests integration tests RCTLoggingTests work in the following way: * Put a custom hook on logging (logging function) to intercept log messages * Send several log messages via JS and see whether they hit the hook as expected The problem with this approach was that there may be unexpected log messages, which squeeze inbetween the points of time when the hook was set and when the first message was sent. There was a (now 6 years old!!!) fix to mitigate this problem, which was adding a lead pause of 2s to "make sure" that all the other possible log messages had been sent: facebook#10568 That didn't actually guarantee fixing the problem in general, just partially mitigating it, as the race condition conceptually still remained there. Here I take a different approach, which should guarantee that we skip all the rogue JS messages before we start sending and reading them on our own: * Install the hook * Log a "marker" message * Pump the log until the marker appears - at this point we know that the hook has been definitely installed Reviewed By: cipolleschi Differential Revision: D40043442 fbshipit-source-id: b4aa617d27c2dcff26682dd72e47ec19cb0d11ca
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Labels
Bug
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
fb-exported
Merged
This PR has been merged.
p: Facebook
Partner: Facebook
Partner
Platform: iOS
iOS applications.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Changelog:
[iOS][Fixed] - Fix race condition in RCTLoggingTests integration tests
RCTLoggingTests work in the following way:
The problem with this approach was that there may be unexpected log messages, which squeeze inbetween the points of time when the hook was set and when the first message was sent.
There was a (now 6 years old!!!) fix to mitigate this problem, which was adding a lead pause of 2s to "make sure" that all the other possible log messages had been sent: #10568
That didn't actually guarantee fixing the problem in general, just partially mitigating it, as the race condition conceptually still remained there.
Here I take a different approach, which should guarantee that we skip all the rogue JS messages before we start sending and reading them on our own:
Differential Revision: D40043442