Skip to content

Commit f201a47

Browse files
committed
fix(settings): avoid setting lambdaTimeout
Problem: Since 6f50d9a some customers have reported that `aws.samcli.lambdaTimeout` is set to `1234`, which is a temporary value that we use to check if settings are working, and is not supposed to be permanently saved in the user `settings.json`. #4004 Solution: Mitigate the issue by: - Always removing the temporary sentinel value, even if it wasn't set by this vscode session. - Use a higher value 91234 so that, in the worst case, the value is still roughly the same as the default of 90000.
1 parent 7d8094a commit f201a47

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/shared/settings.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,20 @@ export class Settings {
9595
public async isValid(): Promise<boolean> {
9696
const key = 'aws.samcli.lambdaTimeout'
9797
const config = this.getConfig()
98+
const tempValOld = 1234 // Legacy temp value we are migrating from.
99+
const tempVal = 91234 // Temp value used to check that read/write works.
98100
const defaultVal = settingsProps[key].default
99101

100102
try {
101-
const oldVal = config.get<number>(key)
102-
// Try to write to settings.json.
103-
await config.update(key, 1234, this.updateTarget)
104-
// Restore the old value, if any.
105-
if (oldVal === undefined || defaultVal === oldVal) {
106-
// vscode will return the default even if there was no entry in settings.json.
107-
// Avoid polluting the user's settings.json unnecessarily.
103+
const userVal = config.get<number>(key)
104+
// Try to write a temporary "sentinel" value to settings.json.
105+
await config.update(key, tempVal, this.updateTarget)
106+
if (userVal === undefined || [defaultVal, tempValOld, tempVal].includes(userVal)) {
107+
// Avoid polluting the user's settings.json.
108108
await config.update(key, undefined, this.updateTarget)
109109
} else {
110-
await config.update(key, oldVal, this.updateTarget)
110+
// Restore the user's actual setting value.
111+
await config.update(key, userVal, this.updateTarget)
111112
}
112113

113114
return true

0 commit comments

Comments
 (0)