-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix console error #4252
Fix console error #4252
Conversation
043e56e
to
5b42edd
Compare
src/reanimated2/initializers.ts
Outdated
Object.defineProperties(global.console, { | ||
debug: { ...props, value: runOnJS(capturableConsole.debug) }, | ||
log: { ...props, value: capturableConsole.log }, | ||
warn: { ...props, value: capturableConsole.warn }, | ||
error: { ...props, value: capturableConsole.error }, | ||
info: { ...props, value: capturableConsole.info }, | ||
}); |
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.
Do we need this change? I thought it worked without those.
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.
We don't need it, but it lets us get rid of @ts-ignore
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.
I'm not familiar with react-native-reanimated
code, but what is the purpose of this Object.defineProperties(...)
statement and why only debug
is wrapped in runOnJS
and the other ones not?
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.
I mean someone in that issue mentioned that they commented out the global.console assignment. Should they expect that something will not work without it? I just downgraded back to v2 instead for now until this is fixed.
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.
We don't need it, but it lets us get rid of @ts-ignore
I think the problem with TypeScript is rather related to the fact that we don't implement all console.*
methods but only a subset of them.
why only debug is wrapped in
runOnJS
and the other ones not?
+1 to this question
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.
Is it really expected to remove all : runOnJS except on debug ?
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.
In the current implementation all console.* methods are wrapped by runOnJS
, I don't think we want to remove it now.
https://github.com/software-mansion/react-native-reanimated/blob/main/src/reanimated2/initializers.ts#L172-L176
debug: runOnJS(capturableConsole.debug),
log: runOnJS(capturableConsole.log),
warn: runOnJS(capturableConsole.warn),
error: runOnJS(capturableConsole.error),
info: runOnJS(capturableConsole.info),
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.
Yes, we don't want to remove any runOnJS
, it was a typo 😅
Tested locally on my side, I confirm it fixes the crash in debug mode, but I have following crash in release mode:
|
@Latropos could you test it in release build also? |
@freeboub The crash on release was because of the refactor - we can't call defineProperties on console on release build, since console in not an object on release. Hope it's fixed
|
I can confirm that the "property is not configurable" error does not occur with the latest change in this PR and the release build does not crash in my repro project: https://github.com/mlazari/ReanimatedRepro/tree/fix-pr |
It looks like the global.console assignment affects console.trace(): https://github.com/mlazari/ReanimatedRepro/blob/console-trace/App.tsx#L63 |
@mlazari I wasn't able to reproduce this problem with |
Can we make a release for this patch, please?? |
@chakravarthi-bb you can append |
+1 on making a release for this patch |
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary Fix this issue: software-mansion#4225 Looks like we have been overwriting console and making its properties not configurable. This PR should fix the problem. ## Test plan Tested on example app --------- Co-authored-by: Aleksandra Cynk <aleksandracynk@aleksandras-mbp.home> Co-authored-by: Aleksandra Cynk <aleksandracynk@swmansion.com> Co-authored-by: Krzysztof Piaskowy <krzysztof.piaskowy@swmansion.com>
@monicatiba Are you sure that is related to react-native-reanimated? The stack trace looks different from the one in #4225 and as far as I can tell that is fixed in the latest version. |
@monicatiba I had this same error and stack trace. for me the problem was that I was applying a |
Summary
Fix this issue: #4225
Looks like we have been overwriting console and making its properties not configurable. This PR should fix the problem.
Test plan
Tested on example app