Skip to content

Commit e2a46bc

Browse files
committed
Call dictionary update commands sequentially
1 parent c7c04e9 commit e2a46bc

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

ab-testing/deploy-lambda/src/lib/deploy.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,32 @@ export const fetchAndDeployArtifacts = async (deployments: ArtifactInfo[]) => {
1919
const CONFIG_PREFIX = `${STAGE}/config/ab-testing`;
2020

2121
try {
22-
await Promise.all(
22+
const artifacts = await Promise.all(
2323
deployments.map(async ({ artifact, dictionary }) => {
2424
console.log(
2525
`Fetching artifact /${ARTIFACT_BUCKET_NAME}${CONFIG_PREFIX}/${artifact} from S3 and deploying to Fastly dictionary ${dictionary.name}`,
2626
);
27-
const abTestGroups = await fetchDictionaryArtifact(
28-
ARTIFACT_BUCKET_NAME,
29-
`${CONFIG_PREFIX}/${artifact}`,
30-
);
31-
return await deployDictionary(dictionary, abTestGroups);
27+
return {
28+
dictionary,
29+
keyValues: await fetchDictionaryArtifact(
30+
ARTIFACT_BUCKET_NAME,
31+
`${CONFIG_PREFIX}/${artifact}`,
32+
),
33+
};
3234
}),
3335
);
36+
37+
for (const [i, { dictionary, keyValues }] of artifacts.entries()) {
38+
await deployDictionary(dictionary, keyValues);
39+
console.log(
40+
`Successfully deployed artifact to Fastly dictionary ${dictionary.name}`,
41+
);
42+
if (i !== artifacts.length - 1) {
43+
// Adding a small delay between deployments to avoid overwhelming Fastly API,
44+
// and ensure dictionaries are updated in order.
45+
await new Promise((resolve) => setTimeout(resolve, 500));
46+
}
47+
}
3448
} catch (error) {
3549
console.error("Error in fetchAndDeployArtifacts:", error);
3650
throw error;

0 commit comments

Comments
 (0)