Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
📝 WalkthroughWalkthroughThe changes implement MQTT payload size limit enforcement (125 KB) across the serverless dev environment. The shim serializes messages and validates size before publishing; oversized payloads trigger structured error notifications instead of normal responses. The dev server subscribes to error topics to receive and process these limit notifications. Changes
Sequence Diagram(s)sequenceDiagram
participant Function as Function Handler
participant Shim as Shim (Dev Mode)
participant MQTT as MQTT Broker
participant DevServer as Dev Server
Function->>Shim: publish(message)
Shim->>Shim: serialize payload
Shim->>Shim: check size ≤ 125 KB
alt Payload within limit
Shim->>MQTT: publish to function topic
MQTT->>DevServer: deliver message
DevServer->>DevServer: process normal response
Note over DevServer: Add requestId & publish
else Payload exceeds limit
Shim->>Shim: buildMinimalEvent()
Shim->>MQTT: publish error to /error topic
MQTT->>DevServer: deliver error notification
DevServer->>DevServer: process error notification
DevServer->>MQTT: publish PayloadTooLargeError
Shim->>Shim: throw error
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Important Action Needed: IP Allowlist UpdateIf your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:
Failure to add the new IP will result in interrupted reviews. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
When requests or responses exceed AWS IoT Core's 128 KB MQTT payload limit during
serverless dev, the connection silently breaks with awrite ECONNRESETerror. This leaves developers in a "zombie state" where the CLI appears connected but all subsequent invocations fail.Solution
Added proactive payload size checks (125 KB safety limit) in both directions:
Request Path (Shim → Local)
/<functionName>/errortopicResponse Path (Local → Shim)
Buffer.byteLength()for accurate UTF-8 handlingPayloadTooLargeErrorback to shim and log to CLICLI Feedback
/<functionName>/errortopics for each functionawsRequestIdChanges
/\/request$/(prevents issues if service/stage is named "request")Buffer.byteLength()instead of.lengthfor accurate byte countingTesting
Verified manually:
serverless devSummary by CodeRabbit