That's an esbuild option we set to indicate it's b...
# general
t
That's an esbuild option we set to indicate it's being built for node (as opposed to browser or something else)
m
Copy code
Error: There was a problem transpiling the Lambda handler: ✘ [ERROR] Top-level await is not available in the configured target environment ("node14")

    src/http.ts:5:0:
      5 │ await interp.loadState();
        ╵ ~~~~~
    at Object.bundle (/Users/cyber/dev/buttes.bot/node_modules/@serverless-stack/core/dist/runtime/handler/node.js:230:23)
    at Object.bundle (/Users/cyber/dev/buttes.bot/node_modules/@serverless-stack/core/dist/runtime/handler/handler.js:19:16)
    at new Function (/Users/cyber/dev/buttes.bot/node_modules/@serverless-stack/resources/src/Function.ts:362:39)
    at Function.fromDefinition (/Users/cyber/dev/buttes.bot/node_modules/@serverless-stack/resources/src/Function.ts:514:14)
    at Api.createFunctionIntegration (/Users/cyber/dev/buttes.bot/node_modules/@serverless-stack/resources/src/Api.ts:579:23)
    at Api.addRoute (/Users/cyber/dev/buttes.bot/node_modules/@serverless-stack/resources/src/Api.ts:466:26)
    at /Users/cyber/dev/buttes.bot/node_modules/@serverless-stack/resources/src/Api.ts:303:12
    at Array.forEach (<anonymous>)
    at Api.addRoutes (/Users/cyber/dev/buttes.bot/node_modules/@serverless-stack/resources/src/Api.ts:302:25)
Copy code
{
  "include": [
    "stacks",
    "src"
  ],
  "compilerOptions": {
    "target": "ES2022",
    "module": "esnext",
    "moduleResolution": "node",
    "lib": [
      "es2020"
    ],
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  }
}
Copy code
const layer = new TclLayer(this, "TclLayer");
    scope.setDefaultFunctionProps({
      layers: [layer],
      runtime: "nodejs14.x",
      bundle: { format: "esm" },
    });
t
set it to
target: es2017
m
same error
t
ok it looks like your bundle.esm setting isn't being picked up
because we have a conditional that if esm is set, we set target to
esnext
instead of
node14
m
i'm not overriding
bundle
anywhere
Copy code
import * as sst from "@serverless-stack/resources";
import { TclLayer } from "./resources/layer";

export default class MainStack extends sst.Stack {
  constructor(scope: <http://sst.App|sst.App>, id: string, props?: sst.StackProps) {
    super(scope, id, props);

    const layer = new TclLayer(this, "TclLayer");
    scope.setDefaultFunctionProps({
      layers: [layer],
      runtime: "nodejs14.x",
      bundle: { format: "esm" },
    });

    // Create a HTTP API
    const api = new sst.Api(this, "Api", {
      routes: {
        "GET /event": "src/http.eventHandler",
        "GET /eval": "src/http.evalHandler",
        "GET /auth": "src/http.authHandler",
      },
    });

    // Show the endpoint in the output
    this.addOutputs({
      ApiEndpoint: api.url,
    });
  }
}
t
When function props are merged bundle isn't merged, it's replaced (probably something we should change, but the entire api probably deserves another look over)
m
i'm not replacing bundle with anything though
t
switch it to
stack.setDefaultFunctionProps
m
ok
got it
thx
i have this other problem, that it just hangs on "Deploying stacks" forever
Copy code
verbose"

SST: 0.69.6
CDK: 2.15.0
Determining if we're on an EC2 instance.
Does not look like an EC2 instance.
Using stage: mish
Preparing your SST app
synth {
  output: '.build/cdk.out',
  app: 'node .build/run.js',
  rollback: true,
  roleArn: undefined,
  verbose: 2,
  noColor: false
}
CDK toolkit version: 2.15.0 (build 151055e)
Command line arguments: {
  _: [ 'synth' ],
  'version-reporting': false,
  versionReporting: false,
  app: 'node .build/run.js',
  a: 'node .build/run.js',
  output: '.build/cdk.out',
  o: '.build/cdk.out',
  quiet: true,
  q: true,
  verbose: 1,
  v: 1,
  disableVersionCheck: 'true',
  lookups: true,
  'ignore-errors': false,
  ignoreErrors: false,
  json: false,
  j: false,
  debug: false,
  ec2creds: undefined,
  i: undefined,
  'path-metadata': true,
  pathMetadata: true,
  'asset-metadata': true,
  assetMetadata: true,
  'role-arn': undefined,
  r: undefined,
  roleArn: undefined,
  staging: true,
  'no-color': false,
  noColor: false,
  validation: true,
  '$0': 'node_modules/aws-cdk/bin/cdk'
}
merged settings: {
  versionReporting: false,
  pathMetadata: true,
  output: '.build/cdk.out',
  app: 'node .build/run.js',
  context: {},
  debug: false,
  assetMetadata: true,
  toolkitBucket: {},
  staging: true,
  bundlingStacks: [ '*' ],
  lookups: true
}
Determining if we're on an EC2 instance.
Does not look like an EC2 instance.
Toolkit stack: CDKToolkit
Setting "CDK_DEFAULT_REGION" environment variable to eu-west-1
Resolving default credentials
Retrieved account ID 178183757879 from disk cache
Setting "CDK_DEFAULT_ACCOUNT" environment variable to 178183757879
context: {
  'aws:cdk:enable-path-metadata': true,
  'aws:cdk:enable-asset-metadata': true,
  'aws:cdk:disable-version-reporting': true,
  'aws:cdk:bundling-stacks': [ '*' ]
}
outdir: .build/cdk.out
env: {
  CDK_DEFAULT_REGION: 'eu-west-1',
  CDK_DEFAULT_ACCOUNT: '178183757879',
  CDK_CONTEXT_JSON: '{"aws:cdk:enable-path-metadata":true,"aws:cdk:enable-asset-metadata":true,"aws:cdk:disable-version-reporting":true,"aws:cdk:bundling-stacks":["*"]}',
  CDK_OUTDIR: '.build/cdk.out',
  CDK_CLI_ASM_VERSION: '16.0.0',
  CDK_CLI_VERSION: '2.15.0'
}
[dotenv][DEBUG] did not match key and value when parsing line 1: # These variables are only available in your SST code.
[dotenv][DEBUG] did not match key and value when parsing line 2: # To apply them to your Lambda functions, checkout this doc - <https://docs.serverless-stack.com/environment-variables#environment-variables-in-lambda-functions>
[dotenv][DEBUG] did not match key and value when parsing line 3: 
[dotenv][DEBUG] did not match key and value when parsing line 5: 
Building function src/http.eventHandler
Building function src/http.evalHandler
Building function src/http.authHandler

Deploying stacks
deploy stack: started mish-buttesbot-main
deploy stack: get pre-deploy status
deploy stack: get pre-deploy status: stack does not exist
deploy stack: addInUseExports
deploy stack: isTemplateChanged
deploy stack: run cdk deploy
deploy stack: poll stack status
deploy stack: poll stack status: unknown
deploy stack: poll stack status: unknown
deploy stack: poll stack status: unknown
deploy stack: poll stack status: unknown
deploy stack: poll stack status: unknown
^C
➜  buttes.bot git:(master) ✗ nr deploy -- --verbose

> buttesbot@0.1.0 deploy
> AWS_PROFILE=mish sst deploy "--verbose"

SST: 0.69.6
CDK: 2.15.0
Determining if we're on an EC2 instance.
Does not look like an EC2 instance.
Using stage: mish
Preparing your SST app
synth {
  output: '.build/cdk.out',
  app: 'node .build/run.js',
  rollback: true,
  roleArn: undefined,
  verbose: 2,
  noColor: false
}
CDK toolkit version: 2.15.0 (build 151055e)
Command line arguments: {
  _: [ 'synth' ],
  'version-reporting': false,
  versionReporting: false,
  app: 'node .build/run.js',
  a: 'node .build/run.js',
  output: '.build/cdk.out',
  o: '.build/cdk.out',
  quiet: true,
  q: true,
  verbose: 1,
  v: 1,
  disableVersionCheck: 'true',
  lookups: true,
  'ignore-errors': false,
  ignoreErrors: false,
  json: false,
  j: false,
  debug: false,
  ec2creds: undefined,
  i: undefined,
  'path-metadata': true,
  pathMetadata: true,
  'asset-metadata': true,
  assetMetadata: true,
  'role-arn': undefined,
  r: undefined,
  roleArn: undefined,
  staging: true,
  'no-color': false,
  noColor: false,
  validation: true,
  '$0': 'node_modules/aws-cdk/bin/cdk'
}
merged settings: {
  versionReporting: false,
  pathMetadata: true,
  output: '.build/cdk.out',
  app: 'node .build/run.js',
  context: {},
  debug: false,
  assetMetadata: true,
  toolkitBucket: {},
  staging: true,
  bundlingStacks: [ '*' ],
  lookups: true
}
Determining if we're on an EC2 instance.
Does not look like an EC2 instance.
Toolkit stack: CDKToolkit
Setting "CDK_DEFAULT_REGION" environment variable to eu-west-1
Resolving default credentials
Retrieved account ID 178183757879 from disk cache
Setting "CDK_DEFAULT_ACCOUNT" environment variable to 178183757879
context: {
  'aws:cdk:enable-path-metadata': true,
  'aws:cdk:enable-asset-metadata': true,
  'aws:cdk:disable-version-reporting': true,
  'aws:cdk:bundling-stacks': [ '*' ]
}
outdir: .build/cdk.out
env: {
  CDK_DEFAULT_REGION: 'eu-west-1',
  CDK_DEFAULT_ACCOUNT: '178183757879',
  CDK_CONTEXT_JSON: '{"aws:cdk:enable-path-metadata":true,"aws:cdk:enable-asset-metadata":true,"aws:cdk:disable-version-reporting":true,"aws:cdk:bundling-stacks":["*"]}',
  CDK_OUTDIR: '.build/cdk.out',
  CDK_CLI_ASM_VERSION: '16.0.0',
  CDK_CLI_VERSION: '2.15.0'
}
[dotenv][DEBUG] did not match key and value when parsing line 1: 
Building function src/http.eventHandler
Building function src/http.evalHandler
Building function src/http.authHandler

Deploying stacks
deploy stack: started mish-buttesbot-main
deploy stack: get pre-deploy status
deploy stack: get pre-deploy status: stack does not exist
deploy stack: addInUseExports
deploy stack: isTemplateChanged
deploy stack: run cdk deploy
deploy stack: poll stack status
deploy stack: poll stack status: unknown
deploy stack: poll stack status: unknown
just hangs
looks like CDKToolkit is stuck in "review" status maybe that's why
f
@Mischa Spiegelmock can you try removing the CDKToolkit from the CFN console and try deploying again?
m
yeah i think that fixed it, thanks
f
just curious, have u killed a previous deploy by any chance?
m
i must have
f
Got it! We’ve got an open issue for this https://github.com/serverless-stack/serverless-stack/issues/220 bumping up the priority
Hey @Mischa Spiegelmock, quick update on this. Just added some auto-handling for this. On deploy if SST finds the CDKToolkit stack is stuck in
REVIEW_IN_PROGRESS
, it will remove it and recreate.
v1.0.0-beta.23
m
Dope thx!