Skip to content
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

Investigate what happened to unhandled rejection #4194

Closed
Timer opened this issue Mar 21, 2018 · 7 comments
Closed

Investigate what happened to unhandled rejection #4194

Timer opened this issue Mar 21, 2018 · 7 comments
Milestone

Comments

@Timer
Copy link
Contributor

Timer commented Mar 21, 2018

#4193

@Timer Timer added this to the 2.0.0 milestone Mar 21, 2018
@bradfordlemley
Copy link
Contributor

FYI, according to this ci run, the lint error was:

/home/travis/build/facebook/create-react-app/packages/react-error-overlay/src/utils/getStackFrames.js
16:3 warning 'unhandledRejection' is assigned a value but never used no-unused-vars

@iansu
Copy link
Contributor

iansu commented Mar 21, 2018

I think the question here is what changed that made that error appear?

@bradfordlemley
Copy link
Contributor

bradfordlemley commented Mar 21, 2018

Yeah, just wanted to note the error here to hopefully save someone some time figuring out why it appeared :) (as in ... obviously, it's a valid error, but why did it just start appearing?)

@NMinhNguyen
Copy link
Contributor

NMinhNguyen commented Mar 22, 2018

Could it be because of https://github.com/facebook/create-react-app/pull/4187/files? https://eslint.org/docs/rules/no-unused-vars says that

By default this rule is enabled with all option for variables and after-used for arguments.

However, that PR uses the all option for arguments. I'm gonna try to see if changing it to the default option instead makes the error go away. I personally think that after-used is a reasonable option for arguments.

UPDATE:

I think I've figured out what's going on. eslint/eslint#8040 (comment) seems to confirm that the previous code should've passed eslint.

function getStackFrames(
  error: Error,
  unhandledRejection: boolean = false,
  contextSize: number = 3
): Promise<StackFrame[] | null> {
  // ...
}

However, eslint/eslint#8459 seems to have broken it, because I took the current master, reverted the commit (including the new test cases), added a new test case similar to the issue we're having, and it passed (and it does fail on master, as expected):

NMinhNguyen/eslint@master...NMinhNguyen:no-unused-vars-repro-after-used-default-fn-params#diff-982d705c981c706fd513f006b18166c5R87

I'll try to raise an issue on eslint's issue tracker and try to prepare a PR as well, but realistically I probably won't get round to doing all of this until the weekend.

That being said, I think that for CRA it still makes sense not to error on all unused arguments. If you change the eslint rule to args: "after-used",, and remove the default parameter from thegetStackFrames function, then eslint doesn't complain. Also makes me realise that changing this setting is probably a breaking change and would need to be mentioned as such in the changelog.

 function getStackFrames(
   error: Error,
-  unhandledRejection: boolean = false,
+  unhandledRejection: boolean,
   contextSize: number = 3

@Timer
Copy link
Contributor Author

Timer commented Mar 26, 2018

Sorry, this was not clear at all.
Unhandled rejections used to be handled differently than normal errors so that the overlay would designate that the error was from a Promise.
It seems now that this distinction is gone.

@Timer Timer modified the milestones: 2.0.x, 2.x Sep 26, 2018
@Marcholio
Copy link

Is there any update on this, can this be closed?

@iansu iansu modified the milestones: 2.x, 3.x Mar 10, 2019
@mrmckeb
Copy link
Contributor

mrmckeb commented Jun 16, 2021

@Timer I'll close this one off as we're not sure if it's still relevant, but please let me know if it is.

@mrmckeb mrmckeb closed this as completed Jun 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants