-
Notifications
You must be signed in to change notification settings - Fork 78
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
JsonParseError: Parsing --target-org intermittent error on running sf commands #2423
Comments
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. |
If I set some retries in the test run, the same commands that fail eventually work. I thought it may have been a problem with having multiple concurrent workers trying to read the same file maybe? So I lowered the number of workers to 1, but it still doesn't work after that. I tried looking at the code in the stack trace, it's this line that's always where the fail happens:
I tried printing in the console what was causing the JSONParseError when it would happen but the output doesn't make sense to me to be able to debug it, it seems it's just trying to parse regular valid json... |
It's an issue with concurrency of config files. We have it on our radar to fix but it's not a small change and we'll need to do some planning for how to roll it out. |
@erocheleau that warning indicates that the file isn't good json. Like @shetzel said, it's probably getting corrupted at some point, probably during your authorization or scratch org creation process. Then when your If you've got any parallel work that might be touching that file, try to eliminate that. |
@W-14085765@ |
@shetzel wow thank you for confirming this at least I know I'm not crazy and I pinpointed the issue correctly 😂 @mshanemc The parallel work is the point of what I'm trying to do, for example to run e2e tests with multiple workers in a CI pipeline, running queries to Salesforce using the CLI. So IMO the concurrency is an issue that should be fixed. But I understand that it's not a small fix and I can work around it now that I know it's confirmed that this is the real cause of the issue. It's funny that it worked without any issue on windows + wsl but on Mac it doesn't work even once. Thanks the replies 👍 |
yeah, there's some ways to deal with that. We massively parallelize e2e tests on orgs by giving them their own isolated directories (see https://github.com/salesforcecli/cli-plugins-testkit).
one theory is that it relates to the keychain stuff on mac. You could experiment with |
To me it really looks like it's because most commands will constantly re-write the json config file for your scratch org instead of leaving it alone? (I could be totally wrong here) But I can log every time there is this error, and every time right now it's when trying to read this file:
Trying to print the content of the file on error returns completely empty. (it could be because the file cannot be opened to read too I guess because something else is still writing in it?)
I added the I changed the code of the read method of configFile.js to
And it completely prints as empty every time this error shows up. (I still have the error show up now with even just 1 working while running playwright tests. |
It really seems to be tied to constantly re-writing the same config file, because if I comment out the line showcased here, I stop having issues altogether with the JSON parsing of the file... Also from the
I would assume this is exactly what is going on here, multiple calls to sfdx methods executed at the same time (by the test runners, even with 1 runner I am encountering this issue) would all try to call It also looks like the content of the file is being re-written with the exact same content, not re-writing the same content could potentially help???, but I could be wrong it's hard to check what's going on during the execution of these commands. Hopefully this information is helpful to try to resolve the issue? :) |
@erocheleau we shipped a really large change to how configFiles work in today's |
@mshanemc I completely missed this update but just saw the version description of 2.19.7 thank you so much! I will try it right away! |
I can confirm it seems to be working now! |
@mshanemc My sf version is usually up to date, last week it was at least @salesforce/cli/2.31.x, today it is @salesforce/cli/2.32.8. So such errors still happens. |
@MarcTCruz can you open a new issue with all the info about it. Can you also include what kind of org you're deploying to? It may or may not be the same file causing the problem. |
Summary
I am using the
@salesforce/cli
installed through npm.I am using it through a nodejs application (automated tests with playwright, and using the node
exec
command in the test setup phase)Everything is running smoothly on windows (using wsl2) and on CI (using ubuntu runners).
But on a Macbook with a M2 chip (dunno if it matters), I am experiencing very flaky commands.
More specifically, when running
sf data record get --sobject Case --where "where clause" --target-org random_alias --json
I am randomly getting this error:
I am getting the same error:
When running also
sf data get record --target-org random_alias --sobject Case --where "where clause" --json
And also:
sf org open -p "path/to/record" --urlonly --target-org random_alias --json
Expected result
I expect these commands to not fail?
Actual result
These commands randomly fail
System Information
Additional information
The text was updated successfully, but these errors were encountered: