microsoft/vscode-azurestaticwebapps

One setting created firstly disappears after refreshing the "Application Settings" node if add two settings at the same time previously

v-xinda opened this issue · 3 comments

OS: Win 10
Azure Resources extension: v0.6.3-alpha.0
Static Web Apps Extension Version: 20230330.4
Regression: Not a regression

Repro Steps:

  1. Create a static web app -> Expand it -> Expand "Production" node -> Expand "Application Settings" node.
  2. Right click "Application Settings" node -> Click "Add New Setting..." -> Enter a name and value.
  3. Add a new setting again immediately (Make sure there are two "Creating xxx..." at the same time).
  4. Refresh the "Application Settings" node after two settings have been created.
  5. Check whether two settings don't disappear.

Expect:
Two settings don't disappear.

Actual:
One setting created firstly disappears.
actual

Does the setting come back if you refresh again? Does the setting show up on the portal?

@alexweininger The setting doesn't come back after refreshing again, and the setting doesn't show up on the portal.

This is probably happening it because when we're updating the app settings, we're sending the whole JSON payload.

So when request 1 starts updating, request 2 is GETing the old app settings (which don't include setting 1 yet) and then sends a new JSON payload only consisting of setting 2 which immediately overwrite it.

There's a couple of ways that we can handle this:

  • Just block updating when there are other app setting updates occurring
  • Cache the new settings JSON while it's updating. If there are any new requests that come in while that's occurring, just the cached JSON rather than getting it from the remote Azure resource.