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
Bug: "The above error…" should appear after the error message but appears before (for some errors) #22656
Comments
|
The input tag should not have any children. Instead of this you should use input and label tag if you want to write text out of input area. |
|
Hi @aniler0 – I'm aware. :) But when someone makes this mistake, the reporting of the error should be a little different than it is today, and that's what this bug is about. |
|
@Berci-Ionut I can't reproduce that. For me it does show the error: If you can reproduce this in a standalone code sandbox, do feel free to link it here though. |
|
Hmm... Seems like is only reproducing when using NextJS (example here) . In this case I am not sure if the issue is related to react or rather NextJS |
|
Still relevant (just verified in 18.0.0 stable) – this and #18101 are both interesting IMO. |
|
Hi @sophiebits, I would like to work on this issue. |
|
Sure, please feel free to. The first step would be to investigate why this is happening and post a comment here explaining the difference in behavior. Then we can look at the implementation. |
|
The input tag should be a self closing tag |
|
@sylvesterAdewale This is not what the issue is about. The issue is about the ordering of the messages. @sophiebits already responded to this in #22656 (comment). |
|
Oops. I have worked for a while on the issue. I guess I understand why messages are ordering like that. But I didn't know issues can be take. |
|
Hi @MustafaEminn, If you already have worked on this issue then you can surely write a patch for this, I will try to learn from your patch. |
|
We can't run console methods after throwing the error. "The above error occurred..." error is logging by console.error method and the second error "... is a void element..." is throw a new error. If I want to tell in order. What is the solution? If we want to log both of these errors, we can't interrupt the execution without throwing another error. If seems good I can open a pull request. |
|
I don’t think it sounds right to me that it’s not possible to fix this without changing the message. Why can’t we delay the console.error call until we know for sure the error has been logged? We could change where we log it from the updater callback to some other place. |
|
We can delay the console.error with setTimeout but it does not seem an efficient way. If we log the error with console.error instead of throwing a new Error then we can change the order without setTimeout. Because we should log the first "is a void element" message and If we throw an error instantly (assume renderRootSync does not catch the error), execution will be interrupted. That's why I can't manage the second log order. Is interrupting the execution important? If we log the first error with console.error and the second error throw an error, handleError method catches the error and the second error won't be logged. There is good execution. If we change the code structure and log error with console.error instead of throwing a new Error, this doesn't look good. Maybe there is another way to do it but I'm new and I keep learning the React codebase |



sophiebits commentedOct 30, 2021
React version: both latest (17.0.2) and next (18.0.0-alpha-9c8161ba8-20211028)
Steps To Reproduce
<input>hello</input>to trigger the "input is a void element tag" errorLink to code example: https://codesandbox.io/s/cocky-matan-ydmys
The current behavior
Two log lines appear:
The expected behavior
They should be in the other order:
This problem doesn't occur in the same way if a component throws an error. Presumably this goes through a different error handling path because it comes from the host config.
If someone works on this, you may also want to review look at this issue at the same time:
The text was updated successfully, but these errors were encountered: