Hi, has anyone faced these issues? this is the fir...
# pact-js
t
Hi, has anyone faced these issues? this is the first time we seen these.
One or more of the teardown state change handlers has failed
Request Failed - One or more of the setup state change handlers has failed
m
What does your logs say around it? I’d expect to see a state handler attempting to execute, but failing. Perhaps set your logs to
debug
and share
t
this is some of the logs we are seeing
Copy code
2023-10-18T15:03:49.520839Z DEBUG ThreadId(02) verify_interaction{interaction="recommend-dataset-keys-for-elements"}: pact_verifier::provider_client: State change request failed with error error sending request for url (<http://127.0.0.1:62176/_pactSetup>): operation timed out
2023-10-18T15:03:49.521020Z DEBUG ThreadId(02) verify_interaction{interaction="recommend-dataset-keys-for-elements"}: pact_verifier: State Change: "ProviderState { name: "a recommendation can be made", params: {} }" -> Err(Provider state failed: (interaction_id: 66051c9c5088764c2d469d74f855cd957d7d4a7d) Invalid response: error sending request for url (<http://127.0.0.1:62176/_pactSetup>): operation timed out)
2023-10-18T15:03:49.521042Z ERROR ThreadId(02) verify_interaction{interaction="recommend-dataset-keys-for-elements"}: pact_verifier: Provider setup state change for 'a recommendation can be made' has failed - MismatchResult::Error("Invalid response: error sending request for url (<http://127.0.0.1:62176/_pactSetup>): operation timed out", Some("66051c9c5088764c2d469d74f855cd957d7d4a7d"))

2023-10-18T15:03:49.848428Z DEBUG ThreadId(02) pact_verifier::pact_broker: Sending JSON to /pact-version/58527d1d8bd6e127e7e92ccd2feb5450d162b8f5/metadata/c1tdW2xdPXRydWUmc1tdW2N2XT0yMTAw/verification-results using POST: {"providerApplicationVersion":"1","success":false,"testResults":[{"exceptions":[{"message":"One or more of the teardown state change handlers has failed"}],"interactionId":"382004ff8189aa179cedc852efa0e3f5f0096d44","success":false},{"exceptions":[{"message":"One or more of the setup state change handlers has failed"}],"interactionId":"10c1e72196f76471c4ad2979a9a661e57643bb5f","success":false},{"exceptions":[{"message":"One or more of the setup state change handlers has failed"}],"interactionId":"66051c9c5088764c2d469d74f855cd957d7d4a7d","success":false}],"verifiedBy":{"implementation":"Pact-Rust","version":"1.1.11"}}
m
Copy code
a recommendation can be made
looks like that state handler is failing
can you please share the state handler code?
Just a quick one Tony, it looks like you raised a PactFlow support ticket for this. If you wouldn’t mind next time popping the ticket # here so we can avoid double handling that would be super helpful. How did you go with the above btw?
t
@Matt (pactflow.io / pact-js / pact-go) we did with but still have the same error
Copy code
stateHandlers: {
        "a recommendation can be made for elements": () => {
        console.log('state totally handled');
        return Promise.resolve();
        },
      },
    };
also we tried with something like this
Copy code
stateHandlers: {
        "a recommendation can be made for elements": () => {
        console.log('state totally handled');
        return Promise.resolve({includePartialMatches: `1`});
        },
      },
finally got it to somewhat working. However, it is missmatching on the body.
Copy code
recommend-dataset-keys-for-elements (1s loading, 456ms verification)
     Given a recommendation can be made for elements
    returns a response which
      has status code 200 (FAILED)
      includes headers
        "content-type" with value "application/json" (OK)
      has a matching body (FAILED)


Failures:

1) Verifying a pact between REPLACE and REPLACE Given a recommendation can be made for elements - recommend-dataset-keys-for-elements
    1.1) has a matching body
           $ -> Actual map is missing the following keys: datasetKeys, elements
    1.2) has status code 200
           expected 200 but was 400
I added a filter hoping it would fix but still nothing.
Copy code
stateHandlers: {
        "a recommendation can be made for elements": () => {
        console.log('state totally handled');
        return Promise.resolve({includePartialMatches: `1`});
        },
      },
      requestFilter: ( req, res, next ) => {
        res.statusCode = 200;
        next();
      }
    };