Hello everyone! I have a question about the mock s...
# pact-js
a
Hello everyone! I have a question about the mock server not starting correctly, throwing a PID: undefined error. One of the projects I'm working on has a functioning Pact suite using 9.11.0 and pact-node 10.9.7, but when I update to pact@latest, the mock server won't spin up, PID: undefined, and an exit code -2. On another project, I'm starting from scratch and have never been able to get the mock server running due to the same issue. Has anyone else had a similar experience, or know how to fix this issue?
Copy code
[2022-04-12 20:36:34.329 +0000] INFO (4003 on OF060D556SMD6MH): pact-node@10.17.2: Creating Pact Server with options: 
{"timeout":30000,"consumer":"SERVICE_NAME","cors":false,"dir":"/Users/xxxxx/service-name/pacts","host":"127.0.0.1","log":"/Users/xxxxx/service-name/logs/pact.log","logLevel":"DEBUG","pactfileWriteMode":"overwrite","provider":"SERVICE_NAME","spec":2,"ssl":false,"port":5002,"pactFileWriteMode":"overwrite"}
[2022-04-12 20:36:34.357 +0000] DEBUG (4003 on OF060D556SMD6MH): pact-node@10.17.2: Starting pact binary '/Users/xxxxx/service-name/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/darwin-1.88.83/pact/bin/pact-mock-service', with arguments [service --consumer serviceName --cors false --pact_dir /Users/xxxxx/service-name/pacts --host 127.0.0.1 --log /Users/xxxxx/service-name/logs/pact.log --log-level DEBUG --provider providerServiceName --pact_specification_version 2 --ssl false --port 5002 --pact-file-write-mode overwrite]
I can provide trace, if that helps (big block of text).
m
Have you tried the debugging steps in the Pact JS Readme? It should show you how to run the underlying mock service directly, bypassing the JS codebase. If you can run the command with the arguments you can see, it points to some other issue. If it doesn’t run, we can diagnose
Are you on a mac with Rosetta? Have you tried in and outside of rosetta mode?
a
I'm on a mac, but no rosetta. I tried the debugging steps. On the project I'm starting Pact from scratch on, the mock server doesn't start up when running directly from the command. On the project with existing Pact that breaks upon updating >9.11.0, the mock-service does run when running from .bin/
We're also using Yarn and TS. Shouldn't matter, but worth mentioning
m
I’m on a mac, but no rosetta. I tried the debugging steps. On the project I’m starting Pact from scratch on, the mock server doesn’t start up when running directly from the command.
do you get any feedback at all?
is there a ruby runtime embedded in the node_modules directly? If you have
--ignore-scripts
set, that could be why
a
Not a thing. No error log
m
strange. I’m guessing the package didn’t install correctly
a
Does it matter having it in the dev dependencies vs dependencies?
m
no, that shouldn’t make any difference
I’d expect to see it in devDependencies though
What do you see if you run
cat ./node_modules/.bin/pact-mock-service
and also
find . -name "pact-mock-service" | grep "pact/bin" | xargs cat
a
Copy code
#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var pact_standalone_1 = require("../src/pact-standalone");
var cp = require("child_process");
var status = cp.spawnSync(pact_standalone_1.default.mockServiceFullPath, process.argv.slice(2), { stdio: 'inherit' }).status;
process.exit(status);
This returns nothing:
Copy code
find . -name "pact-mock-service" | grep "pact/bin" | xargs cat
No other ruby in this project, and also no
--ignore-scripts
m
ok so your install is failing for some reason
a
Copy code
"@pact-foundation/pact-node@^10.17.2":
  version "10.17.2"
  resolved "<http://npm.companyName.com/@pact-foundation%2fpact-node/-/pact-node-10.17.2.tgz#9fa09cdab8a4a4b83086b174ed6d012bc24e90e7>"
  integrity sha512-RslLuFYItB0uDfKLYXei0ZfAPK0W0nwSwp+Zt7Qyt+Stnea2H4DOucKV03uFSiv3TLVKojut5nF70wfgXyNItQ==
  dependencies:
    "@types/needle" "^2.5.1"
    "@types/pino" "^6.3.5"
    "@types/q" "1.0.7"
    "@types/request" "2.48.2"
    chalk "2.3.1"
    check-types "7.3.0"
    cross-spawn "^7.0.1"
    libnpmconfig "^1.2.1"
    mkdirp "1.0.0"
    needle "^2.6.0"
    pino "^6.11.0"
    pino-pretty "^4.1.0"
    q "1.5.1"
    rimraf "2.6.2"
    sumchecker "^2.0.2"
    tar "^6.1.11"
    underscore "1.12.1"
    unixify "1.0.0"
    unzipper "^0.10.10"
    url-join "^4.0.0"

"@pact-foundation/pact@^9.17.3":
  version "9.17.3"
  resolved "<http://npm.companyName.com/@pact-foundation%2fpact/-/pact-9.17.3.tgz#9621e23e6803385841a3ab29a4162a90b6bcac3e>"
  integrity sha512-AVcScLZsxDDKlO1AuyN7m26Z2EqIt5AA4P8cPGEkokyHf97vbbWlHOPZsgZgzxZXQRnvjNyQnyMwHR69hQ1hew==
  dependencies:
    "@pact-foundation/pact-node" "^10.17.2"
    "@types/bluebird" "^3.5.20"
    "@types/express" "^4.17.11"
    bluebird "~3.5.1"
    body-parser "^1.18.2"
    cli-color "^1.1.0"
    es6-object-assign "^1.1.0"
    es6-promise "^4.1.1"
    express "^4.17.1"
    graphql "^14.0.0"
    graphql-tag "^2.9.1"
    http-proxy "^1.18.1"
    lodash "^4.17.21"
    lodash.isfunction "3.0.8"
    lodash.isnil "4.0.0"
    lodash.isundefined "3.0.1"
    lodash.omit "^4.5.0"
    lodash.omitby "4.6.0"
    pino "^6.5.1"
    pino-pretty "^4.1.0"
    pkginfo "^0.4.1"
    popsicle "^9.2.0"
I did try removing and going for a fresh install
yarn add --dev @pact-foundation/pact
and had no warnings or errors in the install, but I get the same result
m
are you running a local proxy? I’m wondering if it’s causing issues downloading the CLI (it happens as a postinstall step)
What does this show:
Copy code
npm config get ignore-scripts
a
That one returns false
We do run a proxy through Spike. Also vpn, of course, but this happens on or off vpn
A little more information: the project that currently runs on 9.11.0 (but not on latest) has this:
Copy code
"config": {
    "pact_do_not_track": true,
    "pact_binary_location": "<http://artifactory.companyName.com/artifactory/github-dist/pact-foundation/pact-ruby-standalone/releases/download/v1.85.0/>"
  }
m
is that the one that works?
a
right
m
yeah, so that tells me your proxy is messing with shit
you’ll need that in both projects, or to allow your proxy to fetch the actual assets
FYI the latest beta resolves this issue as it bundles all assets in the npm package, so the proxy issues should go away
a
Any rough eta on that release? That would help us out a ton
Also, is there a certain Pact version I would need to install to align with the standalone version?
👍 1
Because...the highest we have stored in our artifactory is 1.88.2
m
probably a few months I’d say
you can use it now though
a
Yeah, because I tried adding the line referencing artifactory, removing and re-adding pact, and still no dice on the mock service.
m
No I'm saying the v3 beta package can be used now
And yes, the version of the standalone needs to match the version in Pact. It's not clearly documented I don't think, let me know the version of Pact you're on and I can let you know
a
The latest standalone we have is 1.88.2, so maybe whichever version matches that
m
Ok can do
Ok that's pretty recent, should work with the latest pact JS stable
a
Installing the beta now to see if that resolves the issue. Unrelated, but I noticed the path to the matchers also changed between 9.11 (whenever that was) and current versions, and I don't think it's documented, or maybe shows the old path in the docs
./node_modules/.bin/pact-mock-service
spins up the mock server with the beta install 🙌
🙌 1
And the mock server spins up when running the test suite 🙏 So glad to see those tests run and fail instead of erroring out.
m
Argh, so I may have confused you.
The fact it’s working with the new beta is good, but that I think just proves your download settings are working (i.e. those package config settings)
there is a V3 interface is the Pact JS package (beta) that doesn’t use those underlying CLIs at all - it uses a new native rust core.
but the existing V2 (what you’re using now) interface is supported in that package and still uses the CLI tools.
in other words, the latest version of Pact should probably work also
but, great to hear!
a
So...any pact beta is v3 and should work, and any release version is v2 and probably will not work at all
Or is it that using v3 is optional in the beta release, and v2 is the default? But even if you're using v2 in the beta, it will still work because the cli tools are packaged up with the rest of the bundle?
m
@pact-foundation/pact
(stable) - uses those CLIs to work
@pact-foundation/pact/@beta-x.x.x
(beta) - has two APIs 1. The same as in stable, which still uses those CLIs to operate 2. A new set of APIs (
PactV3
) which uses a new rust core, and supports newer features So basically, the beta is a super set. Additionally, the beta still bundles the CLI tools because it’s a nice feature - e.g. you can then call can-i-deploy, publish etc. without having to install a separate package