architect / functions

AWS Lambda Node runtime helpers for Architect apps
https://arc.codes
162 stars 37 forks source link

Improve Error Handling for Large Payloads #561

Open samirrayani opened 3 months ago

samirrayani commented 3 months ago

Describe the issue When publishing a payload via SNS (and probably SQS too) that is too large, the response should provide a better warning/message. Instead a TypeError is thrown because there is no Error message in the response

Steps to reproduce Steps to reproduce the behavior:

  1. Create a new lambda and publish a large payload to it (arc.events.publish(...))
  2. See error that says TypeError: @aws-lite/client: SNS.Publish: Cannot read properties of null (reading 'Error')

Expected behavior A clear message indicating why the message was unable to be processed (in our case, too big!)

Screenshots CleanShot 2024-06-05 at 15 02 45 CleanShot 2024-06-05 at 15 03 08

brianleroux commented 3 months ago

wow this is funny…

!!!

samirrayani commented 3 months ago

whoa maybe I should start using queues more? I would always just default to creating an event and add some concurrency but that's a pretty big diff

brianleroux commented 3 months ago

Well, it depends, queues are for for when you don't want concurrency. They are designed for throttling "first in first out". An example would be you need to call an API but are rate limited to 1 request per second. If you have two users making requests one will get throttled and fail…unless if you use a queue and enqueue requests to throttle them (on your side) to 1rps.

Events are the opposite. The pattern is "fan out" when you want to 1-many broadcast as fast as possible.

samirrayani commented 3 months ago

aha! that makes sense. thank you for the explanation 🤠