sst 2.1.22 → 2.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,7 @@ import { loadCurrentTemplateWithNestedStacks, loadCurrentTemplate, } from "aws-c
9
9
  import { ToolkitInfo } from "aws-cdk/lib/api/toolkit-info.js";
10
10
  import { CloudFormationStack, } from "aws-cdk/lib/api/util/cloudformation.js";
11
11
  import { replaceEnvPlaceholders } from "aws-cdk/lib/api/util/placeholders.js";
12
+ import { callWithRetry } from "./util.js";
12
13
  /**
13
14
  * Try to use the bootstrap lookupRole. There are two scenarios that are handled here
14
15
  * 1. The lookup role may not exist (it was added in bootstrap stack version 7)
@@ -119,7 +120,7 @@ export class CloudFormationDeployments {
119
120
  };
120
121
  }
121
122
  const { stackSdk, resolvedEnvironment, cloudFormationRoleArn } = await this.prepareSdkFor(options.stack, options.roleArn);
122
- const toolkitInfo = await ToolkitInfo.lookup(resolvedEnvironment, stackSdk, options.toolkitStackName);
123
+ const toolkitInfo = await callWithRetry(() => ToolkitInfo.lookup(resolvedEnvironment, stackSdk, options.toolkitStackName));
123
124
  // Publish any assets before doing the actual deploy (do not publish any assets on import operation)
124
125
  if (options.resourcesToImport === undefined) {
125
126
  await this.publishStackAssets(options.stack, toolkitInfo, {
@@ -11,6 +11,7 @@ import { CfnEvaluationException } from "aws-cdk/lib/api/evaluate-cloudformation-
11
11
  import { tryHotswapDeployment } from "aws-cdk/lib/api/hotswap-deployments.js";
12
12
  import { changeSetHasNoChanges, CloudFormationStack, TemplateParameters, waitForChangeSet, waitForStackDeploy, waitForStackDelete, } from "aws-cdk/lib/api/util/cloudformation.js";
13
13
  import { blue } from "colorette";
14
+ import { callWithRetry } from "./util.js";
14
15
  const LARGE_TEMPLATE_SIZE_KB = 50;
15
16
  export async function deployStack(options) {
16
17
  const stackArtifact = options.stack;
@@ -18,7 +19,7 @@ export async function deployStack(options) {
18
19
  options.sdk.appendCustomUserAgent(options.extraUserAgent);
19
20
  const cfn = options.sdk.cloudFormation();
20
21
  const deployName = options.deployName || stackArtifact.stackName;
21
- let cloudFormationStack = await CloudFormationStack.lookup(cfn, deployName);
22
+ let cloudFormationStack = await callWithRetry(() => CloudFormationStack.lookup(cfn, deployName));
22
23
  if (cloudFormationStack.stackStatus.isCreationFailure) {
23
24
  debug(`Found existing stack ${deployName} that had previously failed creation. Deleting it before attempting to re-create it.`);
24
25
  await cfn.deleteStack({ StackName: deployName }).promise();
package/cdk/util.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function callWithRetry<T>(cb: () => Promise<T>): Promise<T>;
package/cdk/util.js ADDED
@@ -0,0 +1,17 @@
1
+ export async function callWithRetry(cb) {
2
+ try {
3
+ return await cb();
4
+ }
5
+ catch (e) {
6
+ if ((e.code === "ThrottlingException" && e.message === "Rate exceeded") ||
7
+ (e.code === "Throttling" && e.message === "Rate exceeded") ||
8
+ (e.code === "TooManyRequestsException" &&
9
+ e.message === "Too Many Requests") ||
10
+ e.code === "OperationAbortedException" ||
11
+ e.code === "TimeoutError" ||
12
+ e.code === "NetworkingError") {
13
+ return await callWithRetry(cb);
14
+ }
15
+ throw e;
16
+ }
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sst",
3
- "version": "2.1.22",
3
+ "version": "2.1.24",
4
4
  "bin": {
5
5
  "sst": "cli/sst.js"
6
6
  },
package/runtime/iot.js CHANGED
@@ -6,12 +6,12 @@ export const useIOTBridge = Context.memo(async () => {
6
6
  const iot = await useIOT();
7
7
  const topic = `${iot.prefix}/events`;
8
8
  bus.subscribe("function.success", async (evt) => {
9
- iot.publish(topic, "function.success", evt.properties);
9
+ iot.publish(topic + "/" + evt.properties.workerID, "function.success", evt.properties);
10
10
  });
11
11
  bus.subscribe("function.error", async (evt) => {
12
- iot.publish(topic, "function.error", evt.properties);
12
+ iot.publish(topic + "/" + evt.properties.workerID, "function.error", evt.properties);
13
13
  });
14
14
  bus.subscribe("function.ack", async (evt) => {
15
- iot.publish(topic, "function.ack", evt.properties);
15
+ iot.publish(topic + "/" + evt.properties.workerID, "function.ack", evt.properties);
16
16
  });
17
17
  });
package/sst.mjs CHANGED
@@ -2742,13 +2742,25 @@ var init_iot2 = __esm({
2742
2742
  const iot2 = await useIOT();
2743
2743
  const topic = `${iot2.prefix}/events`;
2744
2744
  bus.subscribe("function.success", async (evt) => {
2745
- iot2.publish(topic, "function.success", evt.properties);
2745
+ iot2.publish(
2746
+ topic + "/" + evt.properties.workerID,
2747
+ "function.success",
2748
+ evt.properties
2749
+ );
2746
2750
  });
2747
2751
  bus.subscribe("function.error", async (evt) => {
2748
- iot2.publish(topic, "function.error", evt.properties);
2752
+ iot2.publish(
2753
+ topic + "/" + evt.properties.workerID,
2754
+ "function.error",
2755
+ evt.properties
2756
+ );
2749
2757
  });
2750
2758
  bus.subscribe("function.ack", async (evt) => {
2751
- iot2.publish(topic, "function.ack", evt.properties);
2759
+ iot2.publish(
2760
+ topic + "/" + evt.properties.workerID,
2761
+ "function.ack",
2762
+ evt.properties
2763
+ );
2752
2764
  });
2753
2765
  });
2754
2766
  }
@@ -3306,6 +3318,23 @@ var init_monitor = __esm({
3306
3318
  }
3307
3319
  });
3308
3320
 
3321
+ // src/cdk/util.ts
3322
+ async function callWithRetry(cb) {
3323
+ try {
3324
+ return await cb();
3325
+ } catch (e) {
3326
+ if (e.code === "ThrottlingException" && e.message === "Rate exceeded" || e.code === "Throttling" && e.message === "Rate exceeded" || e.code === "TooManyRequestsException" && e.message === "Too Many Requests" || e.code === "OperationAbortedException" || e.code === "TimeoutError" || e.code === "NetworkingError") {
3327
+ return await callWithRetry(cb);
3328
+ }
3329
+ throw e;
3330
+ }
3331
+ }
3332
+ var init_util = __esm({
3333
+ "src/cdk/util.ts"() {
3334
+ "use strict";
3335
+ }
3336
+ });
3337
+
3309
3338
  // src/cdk/deploy-stack.ts
3310
3339
  import * as cxapi from "@aws-cdk/cx-api";
3311
3340
  import fs8 from "fs/promises";
@@ -3333,7 +3362,9 @@ async function deployStack(options) {
3333
3362
  options.sdk.appendCustomUserAgent(options.extraUserAgent);
3334
3363
  const cfn = options.sdk.cloudFormation();
3335
3364
  const deployName = options.deployName || stackArtifact.stackName;
3336
- let cloudFormationStack = await CloudFormationStack.lookup(cfn, deployName);
3365
+ let cloudFormationStack = await callWithRetry(
3366
+ () => CloudFormationStack.lookup(cfn, deployName)
3367
+ );
3337
3368
  if (cloudFormationStack.stackStatus.isCreationFailure) {
3338
3369
  debug(
3339
3370
  `Found existing stack ${deployName} that had previously failed creation. Deleting it before attempting to re-create it.`
@@ -3606,6 +3637,7 @@ var LARGE_TEMPLATE_SIZE_KB, FullCloudFormationDeployment;
3606
3637
  var init_deploy_stack = __esm({
3607
3638
  "src/cdk/deploy-stack.ts"() {
3608
3639
  "use strict";
3640
+ init_util();
3609
3641
  LARGE_TEMPLATE_SIZE_KB = 50;
3610
3642
  FullCloudFormationDeployment = class {
3611
3643
  constructor(options, cloudFormationStack, stackArtifact, stackParams, bodyParameter) {
@@ -3896,6 +3928,7 @@ var init_cloudformation_deployments = __esm({
3896
3928
  "src/cdk/cloudformation-deployments.ts"() {
3897
3929
  "use strict";
3898
3930
  init_deploy_stack();
3931
+ init_util();
3899
3932
  CloudFormationDeployments = class {
3900
3933
  sdkProvider;
3901
3934
  constructor(props) {
@@ -3959,10 +3992,12 @@ var init_cloudformation_deployments = __esm({
3959
3992
  };
3960
3993
  }
3961
3994
  const { stackSdk, resolvedEnvironment, cloudFormationRoleArn } = await this.prepareSdkFor(options.stack, options.roleArn);
3962
- const toolkitInfo = await ToolkitInfo.lookup(
3963
- resolvedEnvironment,
3964
- stackSdk,
3965
- options.toolkitStackName
3995
+ const toolkitInfo = await callWithRetry(
3996
+ () => ToolkitInfo.lookup(
3997
+ resolvedEnvironment,
3998
+ stackSdk,
3999
+ options.toolkitStackName
4000
+ )
3966
4001
  );
3967
4002
  if (options.resourcesToImport === void 0) {
3968
4003
  await this.publishStackAssets(options.stack, toolkitInfo, {