Skip to content

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Mar 29, 2022

Since all protocol responses should be verified except for a few exceptions (e.g. DAP's stepBack), the verification should be performed automatically. This can prevent situations like #559 (comment) and also make the API easier to use (getting response from the same method call).

There are 2 exceptions though. Both of them are DAP requests:

  • stepBack doesn't return response "yet".
  • stackTrace's response doesn't match the schema. I think this is something to be fixed in another PR.

This refactor can actually centralize those exceptions and make them easier to manage. And sooner or later they should go anyway.

@ono-max
Copy link
Member

ono-max commented Mar 30, 2022

I like this idea 👍

@ono-max
Copy link
Member

ono-max commented Mar 30, 2022

stackTrace's response doesn't match the schema.

Could you be more specific?

@ko1 ko1 added this to the v1.6.0 milestone Mar 30, 2022
@st0012
Copy link
Member Author

st0012 commented Mar 30, 2022

If you verify the stackTrace request, you'll get

  -------------------
  | Failure Message |
  -------------------

  result:
  {
    "type": "response",
    "command": "stackTrace",
    "request_seq": 10,
    "success": true,
    "message": "Success",
    "body": {
      "stackFrames": [
        {
          "name": "Foo::Bar.a",
          "line": 5,
          "column": 1,
          "source": {
            "name": "debug-20220330-24493-xudwvq.rb",
            "path": "/private/var/folders/yg/hnbymwxd5pn7v94_clc59y6r0000gn/T/debug-20220330-24493-xudwvq.rb",
            "sourceReference": null
          },
          "id": 4
        },
        {
          "name": "<module:Foo>",
          "line": 7,
          "column": 1,
          "source": {
            "name": "debug-20220330-24493-xudwvq.rb",
            "path": "/private/var/folders/yg/hnbymwxd5pn7v94_clc59y6r0000gn/T/debug-20220330-24493-xudwvq.rb",
            "sourceReference": null
          },
          "id": 5
        },
        {
          "name": "<main>",
          "line": 1,
          "column": 1,
          "source": {
            "name": "debug-20220330-24493-xudwvq.rb",
            "path": "/private/var/folders/yg/hnbymwxd5pn7v94_clc59y6r0000gn/T/debug-20220330-24493-xudwvq.rb",
            "sourceReference": null
          },
          "id": 6
        }
      ]
    },
    "seq": 12
  }

  The property '#/body/stackFrames/0/source/sourceReference' of type null did not match the following type: integer

Related code

Even if the fix itself may be simple, fixing this will also affect all the recorded raw tests. So I think it's better to do it in another PR.

@st0012
Copy link
Member Author

st0012 commented Mar 30, 2022

@ono-max btw, I proposed a change in #605

@st0012 st0012 force-pushed the simplify-protocol-requests branch from 264f8c5 to 3146782 Compare April 1, 2022 08:58

def assert_disconnect_result
def cleanup_reader
@reader_thread.raise Detach
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactoring.

send_request 'Runtime.terminateExecution'
res = find_crt_cdp_response
assert_cdp_response 'Runtime.terminateExecution', res
send_cdp_request 'Runtime.terminateExecution'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, I forgot to add cleanup_reader method. Could you add it here, too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated 👍

@st0012 st0012 force-pushed the simplify-protocol-requests branch 3 times, most recently from 16f36ea to 6f6d41e Compare April 2, 2022 11:06
@st0012 st0012 force-pushed the simplify-protocol-requests branch from 6f6d41e to ba7a5fd Compare April 5, 2022 08:26
@st0012
Copy link
Member Author

st0012 commented Apr 5, 2022

@ono-max can you give this another look? thx

@ono-max
Copy link
Member

ono-max commented Apr 6, 2022

Great! LGTM

@ko1 ko1 merged commit 4b2219b into ruby:master Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants