openwallet-foundation / credo-ts

Typescript framework for building decentralized identity and verifiable credential solutions
https://credo.js.org
Apache License 2.0
276 stars 202 forks source link

Credo Mediator fails to shutdown when mediating other Credo agents with no inbound transports set #2042

Open nodlesh opened 2 months ago

nodlesh commented 2 months ago

I have a test where all agents are credo agents. All agents restart with the configuration illustrated below in the test, and the test completes successfully. Bob at the end of the test is the mediator for Acme and Faber. Acme and Faber were restarted without inbound transports set. Any subsequent restarts of Bob fails, it will just hang on agent.shutdown() though Bob will still seem to process inbound and outbound messages; Messages like this,

[2024-09-20T19:02:01.157] [DEBUG] [TSED] - Found session with return routing for message 'a46750b5-42e9-45e8-9382-147b1c34edea' (connection 'a4c06271-7d4d-4d83-8907-73b9d9d40524'
[2024-09-20T19:02:01.157] [DEBUG] [TSED] - Packing message and sending it via existing session WebSocket...
[2024-09-20T19:02:01.158] [DEBUG] [TSED] - Pack outbound message https://didcomm.org/messagepickup/2.0/status
[2024-09-20T19:02:01.162] [DEBUG] [TSED] - Sending message
[2024-09-20T19:02:01.162] [DEBUG] [TSED] - Processed inbound message: {"@type":"https://didcomm.org/messagepickup/2.0/status-request","@id":"500b28ac-eaec-4658-a559-5ca6c8548924","~transport":{"return_route":"all"}}
[2024-09-20T19:02:01.162] [DEBUG] [TSED] - WebSocket sent message successfully.

This is the test specification:

  @T004-RFC0211 @UsesCustomParameters @RFC0025 @Transport_Http @Transport_Ws @normal @AcceptanceTest
  Scenario Outline: Two agents creating a connection using a mediator without having inbound transports
    Given we have "2" agents
      | name  | role      |
      | Acme  | recipient |
      | Bob   | mediator  |
      | Faber | sender    |
    And "Acme" is running with parameters "{"inbound_transports": <acme-inbound-transports>, "outbound_transports": <acme-outbound-transports> }"
    And "Bob" is running with parameters "{"inbound_transports": <bob-inbound-transports>, "outbound_transports": <bob-outbound-transports> }"
    And "Faber" is running with parameters "{"inbound_transports": <faber-inbound-transports>, "outbound_transports": <faber-outbound-transports> }"

    # Create connection, request mediation
    When "Bob" and "Acme" create a new connection
    And "Acme" requests mediation from "Bob"
    And "Bob" grants the mediation request from "Acme"
    Then "Acme" has "Bob" set up as a mediator

    When "Bob" and "Faber" create a new connection
    And "Faber" requests mediation from "Bob"
    And "Bob" grants the mediation request from "Faber"
    Then "Faber" has "Bob" set up as a mediator

    # Create connection through the mediator
    When "Acme" uses "Bob" as a mediator
    And "Faber" uses "Bob" as a mediator
    And "Faber" and "Acme" create a new connection

    @RFC0160
    Examples: Acme and Faber creating a 0160 connection using Bob as a mediator without having inbound transports
      | acme-inbound-transports | acme-outbound-transports | bob-inbound-transports | bob-outbound-transports | faber-inbound-transports | faber-outbound-transports |
      | []                      | ["ws", "http"]           | ["ws", "http"]         | ["ws", "http"]          | []                       | ["ws", "http"]            |