CodeGenieApp / CodeGenieApp/serverless-express

After middleware transiently not completed before lambda ends

オープン
#622 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
5.3k
フォーク
674
PR マージ指標
30日以内にマージされた PR はありません

説明

I recently ran into an issue where code that runs after a call to `res.json` in a given route is not guaranteed to be run before a lambda ends.

My use-case is as follows -

1. `PUT /posts/1`
2. handle database update in route
3. return updated record to client using `res.json`
4. as an _after_ middleware, send event specifying something was changed to AWS SQS

In a regular express server, I expect that the code in step 4 would complete successfully. However, I believe that serverless-express is ending the invocation of the lambda before that code has a chance to complete under certain circumstances.

To be a little more clear, here is a set of logs that represents a successful invocation -
```
START RequestId: d884deec-393a-40d2-93b3-f302d8f0c7fa Version: $LATEST
queuing change event
change event successfully queued
END RequestId: d884deec-393a-40d2-93b3-f302d8f0c7fa
```
and here is a set of logs that represents an unsuccessful invocation -
```
START RequestId: 0a1fc1e7-c8a8-40b0-bf80-076ce4c922e6 Version: $LATEST
queuing change event
END RequestId: 0a1fc1e7-c8a8-40b0-bf80-076ce4c922e6
```

As you can see, under some circumstances, the lambda invocation ends _before_ the process has a chance to complete writing to SQS.

Is it possible that this use-case is not well supported in serverless-express? Let me know if more information is needed or if I am obviously doing something wrong.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず serverless-express の Lambda 呼び出しライフサイクルを確認します。特に、`res.json` が after ミドルウェアおよび保留中の非同期処理とどのように連携するかを確認してください。報告された route と AWS SQS のロギングシナリオを再現します。動作が確実に処理されるか、そのサポートと制限事項が明確に文書化されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
aws, express, javascript, node.js
領域
api, backend, cloud
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。