Unable to debug lambda code on first request because RIC waits to load handler

Abierto
#75 2 comentarios 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
aws, node.js, typescript
Área
cloud, devtools

Línea de trabajo

Comienza en el punto de entrada aws-lambda-ric index.handler y sigue cuándo se inician el dominio de ejecución y el proceso de Node.js en relación con la primera solicitud. Compara esa ruta de inicio con el comportamiento documentado de --inspect y --inspect-brk. Se considera terminado cuando el depurador puede iniciarse después de que RIE/RIC se haya iniciado y conectarse antes de que la primera solicitud llegue al breakpoint.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

  1. Start the RIE/RIC
  2. RIE/RIC would start the node process. This would allow the debugger process to start and the dev could attach to it.
  3. 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.

Lenguaje dominante
TypeScript
Estrellas
224
Forks
60
Merge medio
26 min
PR fusionados (30 d)
2

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de aws/aws-lambda-nodejs-runtime-interface-client

Todos los issues de aws/aws-lambda-nodejs-runtime-interface-client

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.