Skip to content

Commit 4c3b97a

Browse files
dante01yoonampagent
andcommitted
fix(workspace): reject stale config after server errors
Amp-Thread-ID: https://ampcode.com/threads/T-019fc8cd-b288-7161-a590-cd76d51212bf Co-authored-by: Amp <amp@ampcode.com>
1 parent 2c1078a commit 4c3b97a

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/platform/remoteConfig/refreshRemoteConfig.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ describe('refreshRemoteConfig', () => {
220220

221221
expect(remoteConfig.value).toEqual(existingConfig)
222222
expect(window.__CONFIG__).toEqual(existingConfig)
223+
expect(remoteConfigState.value).toBe('error')
224+
expect(remoteConfigErrorStatus.value).toBeNull()
223225
})
224226
})
225227
})

src/platform/remoteConfig/refreshRemoteConfig.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ export async function refreshRemoteConfig(
9090
window.__CONFIG__ = {}
9191
remoteConfig.value = {}
9292
remoteConfigErrorStatus.value = response.status
93-
remoteConfigState.value = 'error'
93+
} else {
94+
remoteConfigErrorStatus.value = null
9495
}
96+
remoteConfigState.value = 'error'
9597
} catch (error) {
9698
if (generation !== refreshGeneration) return
9799
if (signal?.aborted) return

src/platform/workspace/auth/WorkspaceAuthGate.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ describe('WorkspaceAuthGate', () => {
352352
})
353353

354354
it('shows a recoverable error when authenticated config is unavailable', async () => {
355+
mockTeamWorkspacesEnabled.value = true
355356
mockRemoteConfigState.value = 'error'
356357

357358
mountComponent()
@@ -360,6 +361,7 @@ describe('WorkspaceAuthGate', () => {
360361
expect(
361362
screen.getByText("Couldn't load your workspace")
362363
).toBeInTheDocument()
364+
expect(mockWorkspaceStoreInitialize).not.toHaveBeenCalled()
363365
})
364366

365367
it('requires sign out when authenticated config rejects the credential', async () => {

0 commit comments

Comments
 (0)