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

[BUG] sfdx force:org:display thows non related exception even when it works #719

Closed
AllanOricil opened this issue Nov 1, 2020 · 8 comments
Assignees
Labels
bug Issue or pull request that identifies or fixes a bug

Comments

@AllanOricil
Copy link

AllanOricil commented Nov 1, 2020

Summary

Basically I have an org that I did not use for a long time, which is also not expired, and SF started to throw an exception while running sfdx force:org:display -u ANY_ORG_ALIAS, like the one in the image below:

image
obs: this image is from another user that has the same problem as I had.

This exception causes a big problem for automations that uses sfdx. For instance, in Node, if this exception is not catched in a try/catch block, the automation stops, even when the command shows a success result at the end. This started to happen recently, like two months ago I never had this problem. But I can't tell you which version the problem started.

Steps To Reproduce:

I have no idea how you can reproduce it. It happend only for some Scratch Orgs, even when I was not displaying that particular org connection details. For instance, the error was saying something about Org A, while executing sfdx force:org:display -u ORG_B.

But I know how I fixed the problem. To fix this issue I first tried to update sfdx, but it did not work. Then I went to %USERNAME%\.sfdx and deleted the file for the org sfdx was throwing the exception (the one that is displayed) from that folder, and the problem was fixed.

Expected result

sfdx force:org:display should never throw an exception if it displays a success result.

Actual result

sfdx force:org:display throws an exception but it also works

Additional information

SFDX CLI Version(to find the version of the CLI engine run sfdx --version): sfdx-cli/7.78.1-5a65d9dd2f
OS and version: Windows 10

@github-actions
Copy link

github-actions bot commented Nov 1, 2020

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

@AllanOricil AllanOricil changed the title sfdx force:org:display thows non related exception even when it works [BUG] sfdx force:org:display thows non related exception even when it works Nov 2, 2020
@AllanOricil
Copy link
Author

@amphro could you help with this?

@AllanOricil
Copy link
Author

AllanOricil commented Nov 2, 2020

My sfdx logs of when I had the same problem. The sfdx force:org:display was given the connection details for any username/org but it was also displaying error messages, like in the image above. After I deleted the connection, that was related to the org displayed in the error message, from c:\USERNAME\.sfdx sfdx stopped to throw the error.

[
   {
      "name":"sfdx",
      "hostname":"AORUSX7",
      "pid":10492,
      "log":"jsforce",
      "level":50,
      "msg":"{\"code\":\"ENOTFOUND\",\"errno\":\"ENOTFOUND\",\"syscall\":\"getaddrinfo\",\"hostname\":\"resourceful-moose-286285-dev-ed.my.salesforce.com\",\"host\":\"resourceful-moose-286285-dev-ed.my.salesforce.com\",\"port\":443}",
      "time":"2018-11-28T17:31:56.655Z",
      "v":0
   },
   {
      "name":"sfdx",
      "hostname":"AORUSX7",
      "pid":10492,
      "level":50,
      "msg":"getaddrinfo ENOTFOUND resourceful-moose-286285-dev-ed.my.salesforce.com resourceful-moose-286285-dev-ed.my.salesforce.com:443.",
      "time":"2018-11-28T17:31:56.659Z",
      "v":0
   },
   {
      "name":"sfdx",
      "hostname":"AORUSX7",
      "pid":10492,
      "level":50,
      "msg":"[ false,\n  '{\"message\":\"getaddrinfo ENOTFOUND resourceful-moose-286285-dev-ed.my.salesforce.com resourceful-moose-286285-dev-ed.my.salesforce.com:443\",\"status\":1,\"stack\":\"Error: getaddrinfo ENOTFOUND resourceful-moose-286285-dev-ed.my.salesforce.com resourceful-moose-286285-dev-ed.my.salesforce.com:443\\\\n    at errnoException (dns.js:50:10)\\\\n    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)\",\"name\":\"Error\",\"warnings\":[]}' ]",
      "time":"2018-11-28T17:31:56.660Z",
      "v":0
   },
   {
      "name":"sfdx",
      "hostname":"AORUSX7",
      "pid":10492,
      "log":"jsforce",
      "level":50,
      "msg":"{\"code\":\"ENOTFOUND\",\"errno\":\"ENOTFOUND\",\"syscall\":\"getaddrinfo\",\"hostname\":\"resourceful-moose-286285-dev-ed.my.salesforce.com\",\"host\":\"resourceful-moose-286285-dev-ed.my.salesforce.com\",\"port\":443}",
      "time":"2018-11-28T17:31:56.668Z",
      "v":0
   }
]

@amphro
Copy link
Contributor

amphro commented Nov 2, 2020

if this exception is not catched in a try/catch block, the automation stops

Are you listening to stderr in your automation? Here is a blog post I wrote that might help you prevent things like that from breaking your automation in the future.

In terms of the error, the display command does some additional mapping on other orgs to make sure we have up to date information on a scratch org. It is supposed to be cached but sometimes it can't or there may be a bug in there. Honestly, we should probably just remove that logic but that is a little bit more work. I'll mark this as a bug since I don't think we should be throwing errors for a different org when running display, but in all honestly, we probably won't get to this one in a long while. Once we finish open sourcing all the CLI code, I may mark this one as help wanted.

@amphro amphro added the bug Issue or pull request that identifies or fixes a bug label Nov 2, 2020
@AllanOricil
Copy link
Author

AllanOricil commented Nov 2, 2020

@amphro yes, I was doing if(!error && !stderr) doSomething; else return error; I will refactor my code for now to ignore stderr. Thanks and I hope this behavior changes soon.

@mshanemc mshanemc self-assigned this Jan 8, 2021
@mshanemc
Copy link
Contributor

This is hopefully fixed in sfdx-core. It'll work its way through the release process soon.
forcedotcom/sfdx-core#347

@mshanemc
Copy link
Contributor

mshanemc commented Feb 8, 2021

This should be fixed in the new open-source version. You can try it early, here: #835

@mshanemc
Copy link
Contributor

closing because the new plugin-org shipped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue or pull request that identifies or fixes a bug
Projects
None yet
Development

No branches or pull requests

3 participants