aws / aws/aws-toolkit-vscode

Debugging crashes when using Finch

Open
#8,386 5 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
2k
Forks
807
Avg merge
10h 12m
Merged PRs (30d)
7

Description

## Problem
Debugging crashes with an Init Error `ImportModuleError` when using Finch . Finch works fine via SAM CLI `sam local invoke` but SAM CLI lacks debugging capabilities.

## Steps to reproduce the issue

1. Have only Finch installed.
2. Setup a Node Hello World project using SAM CLI
3. Open VS Code, setup launch.json using the VS Toolkit extension helper in the template.yaml
4. Run debugging

## Expected behavior
Expected debugging to fully run through the lambda printing "Hello World" in the terminal output just as 'sam local invoke' does using Finch in the terminal.

## System details (run `AWS: About` and/or `Amazon Q: About`)

- OS: MacOS 26.1 (25B78)
- Visual Studio Code version: 1.106.3 (Universal)
- AWS Toolkit version: 3.89.0
- Amazon Q version: n/a

---

Output from running Debugging

```
2025-12-04 10:38:13.094 [info] Starting Build use cache
2025-12-04 10:38:13.216 [info] Manifest file is changed (new hash: c0e83ff3ce1bd02a0c2a7c02974c24ec) or dependency folder (.aws-sam/deps/ab6d6894-2546-406c-a5db-a8cf1a212524) is missing for (HelloWorldFunction), downloading dependencies and copying/building source
Building codeuri: /Users/sedenfield/Documents/Gitlab/_scratchpad/sam-pod-test/sam-app/hello-world runtime: nodejs24.x architecture: arm64 functions: HelloWorldFunction
2025-12-04 10:38:13.236 [info] Running NodejsNpmBuilder:NpmPack
2025-12-04 10:38:14.744 [info] Running NodejsNpmBuilder:CopyNpmrcAndLockfile
Running NodejsNpmBuilder:CopySource
2025-12-04 10:38:14.747 [info] Running NodejsNpmBuilder:NpmInstall
2025-12-04 10:38:15.912 [info] Running NodejsNpmBuilder:NpmTest
Running NodejsNpmBuilder:CleanUp
2025-12-04 10:38:15.913 [info] Running NodejsNpmBuilder:CopyDependencies
2025-12-04 10:38:16.353 [info] Running NodejsNpmBuilder:CleanUpNpmrc
Running NodejsNpmBuilder:LockfileCleanUp
2025-12-04 10:38:16.354 [info] Running NodejsNpmBuilder:LockfileCleanUp
2025-12-04 10:38:16.509 [info] Build Succeeded

Built Artifacts : ../../../../../../../private/tmp/aws-toolkit-vscode/vsctkdda4ad74/output
Built Template : ../../../../../../../private/tmp/aws-toolkit-vscode/vsctkdda4ad74/output/template.yaml

Commands you can use next
=========================
[*] Validate SAM template: sam validate
[*] Invoke Function: sam local invoke -t ../../../../../../../private/tmp/aws-toolkit-vscode/vsctkdda4ad74/output/template.yaml
[*] Test Function in the Cloud: sam sync --stack-name {{stack-name}} --watch
[*] Deploy: sam deploy --guided --template-file ../../../../../../../private/tmp/aws-toolkit-vscode/vsctkdda4ad74/output/template.yaml
2025-12-04 10:38:27.499 [info] Invoking app.lambdaHandler (nodejs24.x)
2025-12-04 10:38:27.733 [info] Local image was not found.
2025-12-04 10:38:27.733 [info] Removing rapid images for repo public.ecr.aws/sam/emulation-nodejs24.x
2025-12-04 10:38:27.896 [info] Building image...
2025-12-04 10:38:29.304 [info] .
2025-12-04 10:38:29.308 [info] .
2025-12-04 10:38:29.509 [info] .
2025-12-04 10:38:29.620 [info] ..
2025-12-04 10:38:29.628 [info] .
2025-12-04 10:38:29.633 [info] .
2025-12-04 10:38:29.635 [info]
2025-12-04 10:38:29.657 [info] Using local image: public.ecr.aws/lambda/nodejs:24-rapid-arm64.
2025-12-04 10:38:29.658 [info] Mounting /tmp/aws-toolkit-vscode/vsctkdda4ad74/output/HelloWorldFunction as /var/task:ro,delegated, inside runtime container
2025-12-04 10:38:29.746 [info] SAM_CONTAINER_ID: 210a34dade7ab8ecfc09fb819b04bc6b847ee472e87c0ea7904083d0fce67920
2025-12-04 10:38:30.648 [info] START RequestId: 23d069e9-56a1-4e33-b850-192f99cc8690 Version: $LATEST
2025-12-04 10:38:30.777 [info] Debugger listening on ws://0.0.0.0:5858/0cd159e1-d8d5-44e1-8721-d9253f25346b
2025-12-04 10:38:30.779 [info] For help, see: https://nodejs.org/en/docs/inspector
2025-12-04 10:38:34.172 [info] Debugger attached.
2025-12-04 10:38:34.504 [info] 2025-12-04T18:38:34.544Z - ERROR Init Error {"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'app'\nRequire stack:\n- /var/runtime/index.mjs","name":"Runtime.ImportModuleError","stack":["Runtime.ImportModuleError: Error: Cannot find module 'app'","Require stack:","- /var/runtime/index.mjs"," at loadModule (file:///var/runtime/index.mjs:577:13)"," at async UserFunctionLoader.load (file:///var/runtime/index.mjs:508:20)"," at async createRuntime (file:///var/runtime/index.mjs:1221:52)"," at async ignition (file:///var/runtime/index.mjs:1637:21)"]}
2025-12-04 10:38:34.511 [info] Waiting for the debugger to disconnect...
2025-12-04 10:38:34.575 [info] node:internal/process/promises:394
triggerUncaughtException(err, true /* fromPromise */);
^

ImportModuleError [Runtime.ImportModuleError]: Error: Cannot find module 'app'
Require stack:
- /var/runtime/index.mjs
at loadModule (file:///var/runtime/index.mjs:577:13)
at async UserFunctionLoader.load (file:///var/runtime/index.mjs:508:20)
at async createRuntime (file:///var/runtime/index.mjs:1221:52)
at async ignition (file:///var/runtime/index.mjs:1637:21)

Node.js v24.11.0
2025-12-04 10:38:34.579 [info] 04 Dec 2025 18:38:34,625 [ERROR] (rapid) Init failed error=Runtime exited with error: exit status 1 InvokeID=
04 Dec 2025 18:38:34,625 [ERROR] (rapid) Invoke failed InvokeID=cc478fe9-df3f-48e0-b7c7-fe2d5365d62a error=Runtime exited with error: exit status 1
2025-12-04 10:38:34.580 [info] 04 Dec 2025 18:38:34,625 [ERROR] (rapid) Invoke DONE failed: Sandbox.Failure
2025-12-04 10:38:35.585 [info] {"errorType": "Runtime.ImportModuleError", "errorMessage": "Error: Cannot find module 'app'\nRequire stack:\n- /var/runtime/index.mjs", "trace": ["Runtime.ImportModuleError: Error: Cannot find module 'app'", "Require stack:", "- /var/runtime/index.mjs", " at loadModule (file:///var/runtime/index.mjs:577:13)", " at async UserFunctionLoader.load (file:///var/runtime/index.mjs:508:20)", " at async createRuntime (file:///var/runtime/index.mjs:1221:52)", " at async ignition (file:///var/runtime/index.mjs:1637:21)"]}
2025-12-04 10:38:35.585 [info]
2025-12-04 10:38:36.253 [info]
2025-12-04 10:38:36.253 [info] Command stopped: "sam local invoke"
```
Thank you for taking a look.

Contributor guide

Open the contributing guide

Research direction

Start by comparing the generated launch.json and template.yaml used by the VS Toolkit extension with the successful sam local invoke path, using the provided ImportModuleError output as the failure case. Reproduce the Node Hello World debug flow with Finch; done means debugging completes and prints "Hello World" without the initialization error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, node.js, typescript, vscode
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.