-
Notifications
You must be signed in to change notification settings - Fork 48.8k
Fix usage of console.error to prevent transform #24188
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
Conversation
I think I also don’t think we want to add a prefix to the message. Instead I suggest to replace |
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.
See above
We were suppressing the `react-internals/warning-args` lint rule for the call to `console.error` in `defaultOnRecoverableError`. As far as I could tell, the lint rule exists because on dev builds, we replace all calls to `console.error` with [this error function](https://github.com/facebook/react/blob/main/packages/shared/consoleWithStackDev.js#L31-L37) which expects a format string + args and nothing else. We were trying to pass in an `Error` object directly. After this commit's change, we will still be passing an `Error` but the transform won't occur.
0ccac09
to
ca25332
Compare
Sorry..,. saw your Workplace comment after sending this PR. Updated to do what you have suggested.
That change was unrelated anyways to the issue at hand but now I'm interested.... isn't this |
No because the error may come from the user code (we just caught it) so we can’t know its type. |
We were suppressing the `react-internals/warning-args` lint rule for the call to `console.error` in `defaultOnRecoverableError`. As far as I could tell, the lint rule exists because on dev builds, we replace all calls to `console.error` with [this error function](https://github.com/facebook/react/blob/main/packages/shared/consoleWithStackDev.js#L31-L37) which expects a format string + args and nothing else. We were trying to pass in an `Error` object directly. After this commit's change, we will still be passing an `Error` but the transform won't occur.
We were suppressing the `react-internals/warning-args` lint rule for the call to `console.error` in `defaultOnRecoverableError`. As far as I could tell, the lint rule exists because on dev builds, we replace all calls to `console.error` with [this error function](https://github.com/facebook/react/blob/main/packages/shared/consoleWithStackDev.js#L31-L37) which expects a format string + args and nothing else. We were trying to pass in an `Error` object directly. After this commit's change, we will still be passing an `Error` but the transform won't occur.
We were suppressing the `react-internals/warning-args` lint rule for the call to `console.error` in `defaultOnRecoverableError`. As far as I could tell, the lint rule exists because on dev builds, we replace all calls to `console.error` with [this error function](https://github.com/facebook/react/blob/main/packages/shared/consoleWithStackDev.js#L31-L37) which expects a format string + args and nothing else. We were trying to pass in an `Error` object directly. After this commit's change, we will still be passing an `Error` but the transform won't occur.
We were suppressing the `react-internals/warning-args` lint rule for the call to `console.error` in `defaultOnRecoverableError`. As far as I could tell, the lint rule exists because on dev builds, we replace all calls to `console.error` with [this error function](https://github.com/facebook/react/blob/main/packages/shared/consoleWithStackDev.js#L31-L37) which expects a format string + args and nothing else. We were trying to pass in an `Error` object directly. After this commit's change, we will still be passing an `Error` but the transform won't occur.
We were suppressing the `react-internals/warning-args` lint rule for the call to `console.error` in `defaultOnRecoverableError`. As far as I could tell, the lint rule exists because on dev builds, we replace all calls to `console.error` with [this error function](https://github.com/facebook/react/blob/main/packages/shared/consoleWithStackDev.js#L31-L37) which expects a format string + args and nothing else. We were trying to pass in an `Error` object directly. After this commit's change, we will still be passing an `Error` but the transform won't occur.
We were suppressing the `react-internals/warning-args` lint rule for the call to `console.error` in `defaultOnRecoverableError`. As far as I could tell, the lint rule exists because on dev builds, we replace all calls to `console.error` with [this error function](https://github.com/facebook/react/blob/main/packages/shared/consoleWithStackDev.js#L31-L37) which expects a format string + args and nothing else. We were trying to pass in an `Error` object directly. After this commit's change, we will still be passing an `Error` but the transform won't occur.
Summary
We were suppressing the
react-internals/warning-args
lint rule for the call toconsole.error
indefaultOnRecoverableError
which was leading to a bug on dev builds. See below.As far as I could tell, the lint rule exists because on dev builds, we replace all calls to
console.error
with this errorfunction which expects a format string + args and nothing else. We were trying to pass in an
Error
object directly. After this commit's change, we will still be passing in anError
object but theconsole.error
call won't be transformed.How did you test this change?
Tested via