microsoft/ptvsd

ptvsd won't stop on uncaught exception on aws sam

koss822 opened this issue · 1 comments

VS Code do not stop debug on uncaught exception in Python3.8 using AWS SAM and VS Code remotely connected to Ubuntu 20.04 running AWS SAM "local invoke".

I specifically tried with ptvsd 4 and also newest version 5.0.0a12.

I still do not have an idea why ptvsd in docker for AWS SAM is not working.

  • VSCode Version: 1.45.1
  • OS Version: Windows 10 1909

Steps to Reproduce:

  1. Install Ubuntu 20.04 LTS in HyperV
  2. Install Python 3.8
  3. Install AWS SAM
  4. Install extension Python and Remote SSH
  5. Create a sample project Hello World in AWS SAM (sam init) and replace code with code below... Also do not forget to add "ptvsd" to requirements.txt
  6. Make sure that "Uncaught exceptions on Breakpoints" are selected
  7. In template directory run sam build && sam local invoke -d 5890
  8. Press F5 to start debug
  9. Code won't stop on uncaught exception

Does this issue occur when all extensions are disabled?: NA
I disabled all extensions excluding Remote-SSH and Python which are required

Visual Studio Code

Version: 1.45.1 (user setup)
Commit: 5763d909d5f12fe19f215cbfdd29a91c0fa9208a
Date: 2020-05-14T08:27:35.169Z
Electron: 7.2.4
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.18363

Remote

Ubuntu 20.04 LTS (HyperV)
Python 3.8
ptvsd 5.0.0a12
SAM CLI, version 0.51.0

System Info

CPUs Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz (8 x 1896)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: enabled
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.85GB (4.54GB free)
Process Argv
Screen Reader no
VM 0%
Remote SSH: hyperv
OS Linux x64 5.4.0-33-generic
CPUs Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz (4 x 1896)
Memory (System) 4.37GB (0.19GB free)
VM 0%

-- Extensions --
Extension Author (truncated) Version
python ms- 2020.5.80290
remote-ssh ms- 0.51.0
remote-ssh-edit ms- 0.51.0

Code

import json
import sys

print("DEV MODE is ENABLED")
import ptvsd
print("Waiting for attach on port 5890")
sys.stdout.flush()
ptvsd.enable_attach(address=('0.0.0.0', 5890))
ptvsd.wait_for_attach()

def lambda_handler(event, context):
    raise Exception("test")

    return {
        "statusCode": 200,
        "body": json.dumps({
            "message": "hello world",
            # "location": ip.text.replace("\n", "")
        }),
    }

CMD

sam build && sam local invoke -d 5890
F5 on file

I believe the exception is technically not uncaught, because the library code that invokes your handler will try to handle it. We are currently working on the feature to allow breaking on *user-*unhandled exceptions (i.e. when exception propagates from user code into library code), which would cover this case.