https://pact.io logo
#pact-js
Title
# pact-js
t

Timothy Gates

03/02/2022, 11:56 PM
Hello everyone, my team updated to version
10.0.0-beta.56
to get the timeout fix https://github.com/pact-foundation/pact-js/issues/761 We are running into an issue were the state handlers teardown is no longer being called. I don't see any change in the signature of the state handlers between
10.0.0-beta.54
and the version we are using now. Anyone have any ideas why the teardown isn't be executed? I'll include an example of the code in the thread.
Code Example:
Copy code
"State Handler": {
        resourceId: undefined,
        setup: async () => {
          console.log("Setup")
          resourceId = await setupState();
          return Promise.resolve({
            queryId: resourceId
          });
        },
        teardown: async () => {
          console.log('Teardown')
          await teardownState(resourceId);
        },
      }
m

Mike Geeves

03/03/2022, 12:38 AM
Not sure timelines of versions but there was a bug whereby the flag to tear down wasn't being used and always did a tear down, on the rust side during a verify: https://github.com/pact-foundation/pact-reference/pull/167 Iirc there's just a flag when calling the verifier to use them
--state-change-teardown
m

Matt (pactflow.io / pact-js / pact-go)

03/03/2022, 12:08 PM
Hi Timothy! hmm, it should support them. Any chance you could please share a debug log for us to take a look at?
The change Mike contributed should be in the latest JS though
m

Mike Geeves

03/03/2022, 12:11 PM
The bug I looked at was it always sent them even without the flag, the logic meant it was always true, so maybe some backwards compatibility issue introduced
m

Matt (pactflow.io / pact-js / pact-go)

03/03/2022, 12:11 PM
ah
m

Mike Geeves

03/03/2022, 12:11 PM
If it is related to that, I forgot to check this morning
On mobile again :) the default was don't send, but the default didn't work
m

Matt (pactflow.io / pact-js / pact-go)

03/03/2022, 12:13 PM
Actually, that handler definition looks incorrect to me
nvm, I’m tired.
I mean, there is a superfluous key there (
resourceId
) but that shouldn’t break things
m

Mike Geeves

03/03/2022, 12:21 PM
I think just calling pact-verifier with --state-change-teardown should do it, if it is related to that
👍 1
m

Matt (pactflow.io / pact-js / pact-go)

03/03/2022, 12:22 PM
That might be it. We moved the core from the CLI version of the verifier to the handle based on. It could be missed in that change
just realised you’re not on the latest. Can you please check out
10.0.0-beta.58
?
Just ran it locally and can see setup/teardown running OK
t

Timothy Gates

03/03/2022, 4:02 PM
I'll try the
--state-change-teardown
and if that doesn't work I'll see about bumping the version to the latest.
👍 1
The
--state-change-teardown
arg didn't have any effect. But bumping to version to
10.0.0-beta.58
did work. The teardowns are now being executed.
🙌 1
m

Mike Geeves

03/03/2022, 4:33 PM
Glad to hear it's working, and also glad it wasn't broken as a result of my fix 😀
m

Matt (pactflow.io / pact-js / pact-go)

03/03/2022, 9:44 PM
Awesome, thanks for confirming Timothy.
We’re back on track with the JS release now - so there will likely be a bunch of more beta updates before we cut over
The main thing left to do is plumb in message pact into the new core and then stabilise the public API
thanks for the feedback!
3 Views