Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vitest - Pact Verifier fails with 3 or more interactions #1220

Open
5 tasks done
shishkin opened this issue Jun 6, 2024 · 8 comments
Open
5 tasks done

Vitest - Pact Verifier fails with 3 or more interactions #1220

shishkin opened this issue Jun 6, 2024 · 8 comments
Labels
bug Indicates an unexpected problem or unintended behavior enhancement Indicates new feature requests help wanted Indicates that a maintainer wants help on an issue or pull request triage This issue is yet to be triaged by a maintainer

Comments

@shishkin
Copy link

shishkin commented Jun 6, 2024

Software versions

  • OS: Mac OSX 14.5
  • Consumer Pact library: Pact JS v12.5.2
  • Provider Pact library: Pact JS v12.5.2
  • Node Version: Node v20.11.1

Issue Checklist

Please confirm the following:

  • I have upgraded to the latest
  • I have the read the FAQs in the Readme
  • I have triple checked, that there are no unhandled promises in my code and have read the section on intermittent test failures
  • I have set my log level to debug and attached a log file showing the complete request/response cycle
  • For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem

Expected behaviour

It should either work or explain clearly what user did wrong.

Actual behaviour

I'm running provider tests and as long as I get 3 or more interactions in the pact file, subsequent interactions start failing due to state change handlers. Weirdly, it fails when I duplicate/copy paste interactions in the pact file, so the same interaction that just succeeded will now fail.

Steps to reproduce

  1. Create an interaction and see it succeed.
  2. Duplicate it twice and see the last one fail.
  3. Move interactions in the file around and see a different one of the same interactions fail.

See test and pact JSON.

Relevant log files

See log.

@shishkin shishkin added bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer labels Jun 6, 2024
@YOU54F
Copy link
Member

YOU54F commented Jun 10, 2024

can you update your packages so pact-js pulls in pact-js-core 14.3.7

i believe this is fixed and your logs show they are running 14.3.6

#1216 (comment)

@shishkin
Copy link
Author

I still observe the same errors with pact-js-core 14.3.7.

@YOU54F
Copy link
Member

YOU54F commented Jun 11, 2024

The error is

libc++abi: terminating due to uncaught exception of type Napi::Error

I can resolve with this workaround, tested locally

vitest-dev/vitest#2972 (comment)

@mefellows
Copy link
Member

Glad you got to the bottom of this Yousaf!

We may need to look into how we can make the core threadsafe, if possible, to enable multi-threaded tests like this (see https://github.com/nodejs/node-addon-api/blob/main/doc/threadsafe.md). For now, that workaround is good to know.

@YOU54F
Copy link
Member

YOU54F commented Jun 11, 2024

no worries man, the reproducer was really helpful, so thanks to @shishkin

It might be worth getting a basic vitest example in place, and utilise this test to reproduce our issue, document the current workaround, and it will help us test out any solutions from the linked doc.

💯 enabling multi-threaded tests would be a nice bonus rather than having to forgoe them

@shishkin
Copy link
Author

Thanks @YOU54F. Indeed, running vitest with --pool=forks resolves the issue. I think I can live with it for now, since provider verifier is only a single test.

@mefellows
Copy link
Member

Thanks @shishkin. If you do feel inclined to go deep to see if we can make it multi-threaded, we'd be happy to give you some pointers (TL;DR - it'll be in here somewhere: https://github.com/pact-foundation/pact-js-core/blob/master/native/provider.cc).

@mefellows mefellows added help wanted Indicates that a maintainer wants help on an issue or pull request enhancement Indicates new feature requests labels Jun 12, 2024
@shishkin
Copy link
Author

@mefellows sorry, I'm not competent in native development to dig in.

@YOU54F YOU54F changed the title Pact Verifier fails with 3 or more interactions Vitest - Pact Verifier fails with 3 or more interactions Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior enhancement Indicates new feature requests help wanted Indicates that a maintainer wants help on an issue or pull request triage This issue is yet to be triaged by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants