-
Notifications
You must be signed in to change notification settings - Fork 69
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
feat!: cross-save resistant configFile #959
Conversation
The Config family of classes' write(sync) method used to accept a param. The value in the param would overwrite the existing file.
src/config/config.ts
Outdated
|
||
if (value == null) { | ||
delete content[propertyName]; | ||
if (value == null || value === undefined) { |
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.
Since value == null
uses the double equals, adding || value === undefined
is redundant.
src/config/config.ts
Outdated
await fs.promises.mkdir(pathDirname(path), { recursive: true }); | ||
await fs.promises.writeFile(path, JSON.stringify(translated, null, 2)); | ||
} catch (error) { | ||
/* Do nothing */ |
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.
Are you 100% positive that swallowing this error will not cause future headaches? Should the error be logged?
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.
No, but I am 100% positive it currently does that. https://github.com/forcedotcom/sfdx-core/pull/959/files/19e4679631ec94d5bbd74ae7e87ff21ac6447f55#diff-615dacd7000fa06d7afef0f22b7b6d9267c6219fbfc9fa0315e51a5f5d963755L629
Logging them sounds like a good idea.
src/config/configFile.ts
Outdated
|
||
// unlock the file | ||
if (typeof unlockFn !== 'undefined') { | ||
await unlockFn(); |
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.
should unlocking be done in a finally where the lock occurs?
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.
If I put the writeFile in a try/finally I think that takes care of the only other place it could fail. See change.
[Property in keyof P]: LWWRegister<P[Property] | typeof SYMBOL_FOR_DELETED>['state']; | ||
}; | ||
|
||
/** |
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.
sfdx-core has generated docs from code so I think it should be added here.
QA Using https://github.com/mdonnalley/crdt-config-test (and single process
two processes🟢 process 1 sets new key last
🟢 process 2 sets new key last
🟢 process 1 sets new key last, process 2 does the last
🟢 process 2 sets new key last, process 1 does the last
🔴 process 1 sets new key then process 2 deletes it, process 1 does final
It should have been 🟢 process 1 sets new key then process 2 deletes it, process 2 does final
|
QA (sf specific) config/alias
in dreamhouse-lwc org create
in dreamhouse-lwc deploy/retrieve
in dreamhouse-lwc |
feat: reusable file locks outside of ConfigFile
refactor: dev-scripts
feat: ts5 and ts-patch
Primary: make configFile save from cross-saving
alias
cross-save problem) are used in the write/writeSync methodsBREAKING CHANGE:
AuthInfo.getFields
now returns a read-only object. Use AuthInfo.update to change values in the fields.BREAKING CHANGE:
setContents
method is no longer available in the ConfigFile stack.BREAKING CHANGE:
awaitEach
is removed from ConfigFile stackBREAKING CHANGE:
write(sync)
method no longer accepts a param. Use other methods (set, unset) to make modifications, then callwrite()
/writeSync()
to do the write.BREAKING CHANGE: the use of lodash-style get/set (ex:
set('foo.bar.baz[0]', 3)
no longer works.BREAKING CHANGE: You can no longer override the
setMethod
andgetMethod
when extending classes built on ConfigFile. Technically you could override get/set, but DON'T!BREAKING CHANGE: everything related to tokens/tokenConfig is gone.
Other changes
Remove previously deprecated stuff since this is a major release
sfdc.isInternalUrl
. Usenew SfdcUrl(url).isInternalUrl()
sfdc.findUppercaseKeys
. There is no replacement.SchemaPrinter
. There is no replacement.also
ttypescript
=>ts-patch
@W-14388558@TODO:
sfdxConfig.merge
What issues does this PR fix or reference?
forcedotcom/cli#2423
forcedotcom/cli#2528
@W-14085765@
Release notes (CLI)
Sometimes the CLI would try to save 2 copies of the same file concurrently, resulting in either an invalid file (busted JSON) or one of the "savers" losing their changes. We've redesigned how files are saved to try to be safer about concurrency.
QA highlights
The code for
sfdxConfig
interop changed quite a bit. Make sure it's still reading/writing that file correctly.Compare perf in things like plugin-settings and plugin-auth where we're writing to these files. the lock stuff could introduce some extra latency.
Check cases (ex: no file exists)
Things outside of core that use ConfigFile to test with