Unable to debug lambda code on first request because RIC waits to load handler
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 35/100
- Issue 類型
- 功能
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- aws, node.js, typescript
研究方向
從 aws-lambda-ric index.handler 進入點開始,追蹤 runtime domain 和 Node.js 程序相對於第一個請求何時啟動。將該啟動路徑與文件中所述的 --inspect 和 --inspect-brk 行為進行比較。當偵錯器能在 RIE/RIC 啟動後啟動並連線,且在第一個請求到達 breakpoint 之前完成連線時,即視為完成。
由索引模型根據 Issue 內容生成。
描述
I use the following command to run Runtime Interface Emulator/Runtime Interface Client:
/usr/local/bin/aws-lambda-rie /usr/bin/npx --node-options="--inspect-brk=0.0.0.0:9229" aws-lambda-ric index.handler
I use VS Code to debug my containerized lambda.
Because of the way the RIE or RIC is instrumented, it doesn't load the node process until the first request is initiated.
Because of this the node debugger process doesn't get launched until after the first request. To get around this, I have to issue the request, it hangs because the debugger is waiting for me to attach to it and give it action, then I attach to it, and only then does the debugger start, otherwise the request just sits.
Note: If I use --inspect instead of --inspect-brk then I have to issue two requests. The first request is when the debugger starts. Once the file is loaded, then I attach to the debugger. Now on the second request I can get proper debugging.
Neither solution is adequate. Ideally, I would
- Start the RIE/RIC
- RIE/RIC would start the node process. This would allow the debugger process to start and the dev could attach to it.
- I'd issue my request and it'd stop exactly at the breakpoint where I needed it to be.
Here is my launch.json file
{
"configurations": [
{
"address": "0.0.0.0",
"localRoot": "${workspaceFolder}",
"name": "Attach to Lambda's Node Debugger Process",
"port": 9229,
"remoteRoot": "/var/task",
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "node",
"continueOnAttach": true
},
]
}
When I start the program here's what happens:
[INFO] (rapid) exec '/usr/bin/npx' (cwd=/var/task, handler=index.handler)
Then I issue an request. Here's what happens:
[INFO] (rapid) Configuring and starting Operator Domain
[INFO] (rapid) Starting runtime domain
START RequestId: d6fe2e68-87d3-4918-bf02-e96665ad7dfa Version: $LATEST
Debugger listening on ws://0.0.0.0:9229/00b2748e-8cc0-492e-8ecf-5d8517802ef7
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
The program stops here because I've initialized it with the --inspect-brk flag so that I don't need to the request twice. (This is where the inefficiency occurs: The process which starts the runtime domain should get initialized earlier and allow the debugger process to get started.)
I then attach to the debugger port and am able to get to my line of code.
- 主要語言
- TypeScript
- 星號
- 224
- 分支
- 60
- 平均合併
- 26 分鐘
- 30 天內合併 PR
- 2
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
aws/aws-lambda-nodejs-runtime-interface-client 的其他 Issue
-
難度 5/5 一週以上 新手友好度 20/100
aws/aws-lambda-nodejs-runtime-interface-client#198 · 6 則留言 · 6 個 reaction ·
-
難度 4/5 3-5 天 新手友好度 48/100
aws/aws-lambda-nodejs-runtime-interface-client#195 · 13 個 reaction ·
-
Upgrading to 4.0.0 appears to break lambdas using docker可能重新可做 @godcrampy 於 295 天前認領,目前沒有進行中的 PR。 未關閉bug
aws/aws-lambda-nodejs-runtime-interface-client#170 · 15 則留言 · 6 個 reaction · 已指派 1 人 ·
-
難度 2/5 1-3 小時 新手友好度 38/100
aws/aws-lambda-nodejs-runtime-interface-client#159 · 2 個 reaction ·
-
難度 4/5 3-5 天 新手友好度 42/100
aws/aws-lambda-nodejs-runtime-interface-client#145 · 1 則留言 · 6 個 reaction ·
查看 aws/aws-lambda-nodejs-runtime-interface-client 的全部 Issue
相似的 Issue
-
enhancement providers-api ui-dashboard
難度 2/5 1-3 小時 新手友好度 61/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 88/100
維護者通常 1 天內回覆
-
external-issue to-triage
難度 1/5 1 小時以內 新手友好度 90/100
維護者通常 1 天內回覆
-
needs triage
難度 1/5 1 小時以內 新手友好度 88/100
homarr-labs/homarr#6976 · 2 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆