[PR #569] [MERGED] feat: add retry mechanism for serverless invocation on 502 errors #590

Closed
opened 2026-02-16 01:16:26 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langgenius/dify-plugin-daemon/pull/569
Author: @Yeuoly
Created: 1/16/2026
Status: Merged
Merged: 1/20/2026
Merged by: @Stream29

Base: mainHead: enhance/lambda-retry


📝 Commits (4)

  • 9c64cee feat: add retry mechanism for serverless invocation on 502 errors
  • a867c70 refactor: simplify retry logic and error handling in serverless invocation
  • eef3305 fix: max time
  • eef8d48 fix: test

📊 Changes

4 files changed (+521 additions, -13 deletions)

View changed files

📝 internal/core/serverless_runtime/io.go (+83 -13)
internal/core/serverless_runtime/io_test.go (+435 -0)
📝 internal/core/serverless_runtime/type.go (+2 -0)
📝 internal/types/app/config.go (+1 -0)

📄 Description

  • Add MAX_SERVERLESS_RETRY_TIMES config (default: 3) for configurable retry attempts
  • Implement exponential backoff retry logic (500ms, 1s, 2s, ...) for 502 Bad Gateway errors
  • Only retry on 502 status code as it indicates transient AWS Lambda gateway issues
  • Add comprehensive test suite with 11 test cases covering all retry scenarios
  • Ensure proper HTTP response body cleanup on retries to prevent resource leaks

Description

Please provide a brief description of the changes made in this pull request.
Please also include the issue number if this is related to an issue using the format Fixes #123 or Closes #123.

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Performance improvement
  • Other

Essential Checklist

Testing

  • I have tested the changes locally and confirmed they work as expected
  • I have added unit tests where necessary and they pass successfully

Bug Fix (if applicable)

  • I have used GitHub syntax to close the related issue (e.g., Fixes #123 or Closes #123)

Additional Information

Please provide any additional context that would help reviewers understand the changes.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langgenius/dify-plugin-daemon/pull/569 **Author:** [@Yeuoly](https://github.com/Yeuoly) **Created:** 1/16/2026 **Status:** ✅ Merged **Merged:** 1/20/2026 **Merged by:** [@Stream29](https://github.com/Stream29) **Base:** `main` ← **Head:** `enhance/lambda-retry` --- ### 📝 Commits (4) - [`9c64cee`](https://github.com/langgenius/dify-plugin-daemon/commit/9c64cee118025abb85f0cb3867c79b88407ac738) feat: add retry mechanism for serverless invocation on 502 errors - [`a867c70`](https://github.com/langgenius/dify-plugin-daemon/commit/a867c70c5388ab1fad8eea37c42b671d75689133) refactor: simplify retry logic and error handling in serverless invocation - [`eef3305`](https://github.com/langgenius/dify-plugin-daemon/commit/eef3305ac2f45b7f579a6365b2f6b8ea73017acb) fix: max time - [`eef8d48`](https://github.com/langgenius/dify-plugin-daemon/commit/eef8d48ac661643fa069a308d383b42f4d7fc54c) fix: test ### 📊 Changes **4 files changed** (+521 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `internal/core/serverless_runtime/io.go` (+83 -13) ➕ `internal/core/serverless_runtime/io_test.go` (+435 -0) 📝 `internal/core/serverless_runtime/type.go` (+2 -0) 📝 `internal/types/app/config.go` (+1 -0) </details> ### 📄 Description - Add MAX_SERVERLESS_RETRY_TIMES config (default: 3) for configurable retry attempts - Implement exponential backoff retry logic (500ms, 1s, 2s, ...) for 502 Bad Gateway errors - Only retry on 502 status code as it indicates transient AWS Lambda gateway issues - Add comprehensive test suite with 11 test cases covering all retry scenarios - Ensure proper HTTP response body cleanup on retries to prevent resource leaks ## Description Please provide a brief description of the changes made in this pull request. Please also include the issue number if this is related to an issue using the format `Fixes #123` or `Closes #123`. ## Type of Change - [ ] Bug fix - [ ] New feature - [ ] Refactor - [ ] Performance improvement - [ ] Other ## Essential Checklist ### Testing - [ ] I have tested the changes locally and confirmed they work as expected - [ ] I have added unit tests where necessary and they pass successfully ### Bug Fix (if applicable) - [ ] I have used GitHub syntax to close the related issue (e.g., `Fixes #123` or `Closes #123`) ## Additional Information Please provide any additional context that would help reviewers understand the changes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 01:16:26 -05:00
yindo closed this issue 2026-02-16 01:16:26 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-plugin-daemon#590