-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[LogBox] Add LogBox.isIgnoredLog()
for expo remote logging integration
#34476
Conversation
Base commit: 163171c |
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
It seems that the @Kudo, could you try and rebase the PR? I should have fixed the CI issues. Thank you so much! |
3da7a23
to
cee34bc
Compare
rebased. thanks for helping the review! |
Base commit: 163171c |
cee34bc
to
afe66ee
Compare
there looks like a network issue from ci job. i'm rebasing again to test again. |
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I think that LogBox.ignoreLogs
is supposed to also silence the logs to the console. Looking at the code, it appears that we do this for console.warn but only do it for console.error if it's from the warning
module.
Instead of this new API, what if we update the code here to also check the ignored logs: https://github.com/facebook/react-native/blob/main/Libraries/LogBox/LogBox.js#L179
I also want to call out that the fix for this issue is not to ignore the warning. See the comment I left on the post. |
please let me describe the problem clearly.
for the code snippet, at first glance, the LogBox has some internal ignored rules as you mentioned. for instance, message starts with hopefully this is clear to you and i am open to the implementation. let me know what's your thought and makes sense to you.
yep! i like your reply for |
Instead of overwriting higher in the stack and passing to both, can you overwrite lower in the stack (i.e. before LogBox)? Then LogBox will be able to handle all of the interpolation and filtering before it gets passed to a lower level. That's how we handle the logs in Metro and it would probably be weird for users if they see a log in Metro but not in other tools. |
from 8abe737068a5 of react-native@0.66.0, |
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@Kudo you have access to the bundler though right? You can inject stdio and lazily init the native modules? |
@rickhanlonii that's achievable. it's just requiring additional setup. i may need to add an injection stdio script at metro's |
I think that's probably the best thing to do here since you're instrumenting the low-level stdio. That means you won't have to re-implement all of the LogBox error parsing logic, which is pretty fragile and tied to specific React/React Native versions. |
I caught up with @Kudo about this on a call, and it occurred to me that we may want to keep the current behavior in Expo projects - in part because of the complexity of the workaround (configuring Metro to inject code before What do you think? I don't want to diverge from React Native on this point - would you be open to a PR to change this behavior in React Native? |
Hm, yeah good point. Let me ask @sshic, who has been working close to the error handling than I have. |
I think this is related to the purpose of |
Yeah great questions @sshic. When I implemented Thinking more about this now, I think I made a mistake, and we actually should never hide console errors and warnings. The referenced issue #33557 is a great reason why - the correct fix for this is not to ignore the errors, it's to address the deprecation / removal of the API. Allowing an easy So I think the right next steps would be:
If folks want to override console methods to filter, can't stop them but it's not recommended. What do you think @sshic @brentvatne @Kudo |
@rickhanlonii - I agree with your reasoning and proposed next steps! |
@rickhanlonii @Kudo Should we then close this PR? |
thanks @cipolleschi! i would close this pr. please try to follow up the mentioned next steps from Meta side when someone get a chance. thank you very much! |
Summary
In Expo environment, we overwrite console log handlers and send logs to CLI terminal or Snack remote console. If users use
LogBox.ignoreLogs()
to suppress some logs, the log will suppress from LogBox but still send to CLI terminal. Toward this problem, the PR introduces aLogBox.isIgnoredLog()
function for us to check whether we should ignore the log entry.This PR will help us to unblock and fix the problem mentioned in #33557 (comment). (with example included)
Changelog
[General] [Added] - Add
LogBox.isIgnoredLog()
function to indicate whether a log is ignoredTest Plan
Unit Test