Giter Site home page Giter Site logo

sst-lambda-stacktrace-debug's Introduction

Simple POC for getting sourcemaps working when deployed

This project was created via:

$ npx create-sst@latest --template=examples/queue

Sourcemaps added from the docs:

export default {
  config() {
    // Config
  },
  stacks(app) {
    app.setDefaultFunctionProps({
      environment: {
        NODE_OPTIONS: "--enable-source-maps",
      },
      bundle: {
        sourcemap: true,
      },
    });

    // Add stacks
  },
} satisfies SSTConfig;

Steps to reproduce the issue

Success

npx sst dev

Use the AWS console to send the message body fail into the AWS SQS Queue that was created, named something like <stage-name>-devops-lambdas-Exampl-QueueConsumerQueue <random-bits>

See the logs for the intentionally thrown error:

โœ”  Deployed:
   ExampleStack
   ApiEndpoint: https://<deleted>.execute-api.us-east-1.amazonaws.com

|  Invoked packages/functions/src/consumer.main
|  Built packages/functions/src/consumer.main
|  +86ms   Message processed: "fail"
|  Error: Error
       at main (<deleted>/devops-lambdas/packages/functions/src/consumer.ts:7:11)
       at file:///<deleted>devops-lambdas/node_modules/sst/support/nodejs-runtime/index.mjs:148:22
       at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Success:
The stack trace correctly identifies line 7 in packages/functions/src/consumer.ts, which does contain the throw statement!!

Failure

npx sst deploy --stage dev

Follow the steps above, but drop it into the queue that is prefixed with dev-, it should be something like dev-devops-lambdas-Exampl-QueueConsumerQueue<random-bits>

Dig the relevant log out of CloudWatch Logs:

2023-10-26T15:39:06.584Z	34b92a5b-f098-5733-8216-77ef7ade2ad7	ERROR	Invoke Error 	{
    "errorType": "Error",
    "errorMessage": "Error",
    "stack": [
        "Error: Error",
        "    at Runtime.main [as handler] (file:///var/task/packages/functions/src/consumer.mjs:14:11)",
        "    at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1173:29)"
    ]
}

Expected Results

packages/functions/src/consumer.mjs:14:11 should match the stack trace when developing locally: packages/functions/src/consumer.ts:7:11

How to use queues in your serverless app (rest of README is autogenerated)

An example serverless app created with SST.

Getting Started

Read the tutorial

Install the example.

$ npx create-sst@latest --template=examples/queue
# Or with Yarn
$ yarn create sst --template=examples/queue
# Or with PNPM
$ pnpm create sst --template=examples/queue

Commands

npm run dev

Starts the Live Lambda Development environment.

npm run build

Build your app and synthesize your stacks.

npm run deploy [stack]

Deploy all your stacks to AWS. Or optionally deploy, a specific stack.

npm run remove [stack]

Remove all your stacks and all of their resources from AWS. Or optionally removes, a specific stack.

Documentation

Learn more about the SST.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.