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

Alex Maiburg

05/31/2022, 7:48 AM
Hi, I updated all pact related packages in Angular (see 1st screenshot) and everything works well on my machine. But when I start the build pipeline on Jenkins I get “[karma-pact]: Failed to start Pact Mock Server Error: Couldn’t start Pact with PID: undefined” I attached the full error log. Can anybody point me to a possible cause? Thanks in advance.
m

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

05/31/2022, 7:54 AM
Copy code
spawn /home/jenkins/project/workspace/feature_dssk-1737-angular-update/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.88.83/pact/bin/pact-mock-service ENOENT
This tells me the package wasn’t properly installed
This is package that is dynamically downloaded during
npm i
Check the troubleshooting tips of the readme, could it be a proxy?
a

Alex Maiburg

05/31/2022, 8:02 AM
Hi Matt, thanks for your quick response. Yes, there’s definitely a proxy involved. I will look into it and let you know.
m

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

05/31/2022, 8:19 AM
👍👍
a

Alex Maiburg

05/31/2022, 9:52 AM
I checked our Artifactory and all packages with the latest versions are present there. So there shouldn’t be a proxy issue… Maybe some adjustments in karma.conf?
m

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

05/31/2022, 9:56 AM
Does it also have the standalone zip file? The pact package on install, goes out to the internet and attempts to download an additional binary (the mock service that is referenced in that log).
If you have a proxy in place that’s preventing that download, it could be the cause
The install process should fail in this case, but it might not for various reasons
a

Alex Maiburg

05/31/2022, 11:30 AM
Yes, it contains the standalone zip file.
m

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

05/31/2022, 11:31 AM
hmm
If you can do it, see if you assess on the build environment if the mock service has been correctly downloaded and installed
A problem I’ve seen in the past, is that the proxy intercepts the download, returns a 200 OK and then writes an HTML file to where a zip file should be
a

Alex Maiburg

05/31/2022, 11:33 AM
Yes, I will upload it to Artifactory and reference it explicitly in the package.json
👍 1
m

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

05/31/2022, 11:34 AM
For clarity, it’s still possible that the proxy can intercept the request to Artifactory
a

Alex Maiburg

05/31/2022, 11:35 AM
Ok, I will give it a shot anyway. In the meantime I will contact our DevOps-Team if they can look into it.
I managed it to upload the binary pact-1.88.83-linux-x86_64.tar.gz to artifactory and added the path to package.json. Everything works well during
npm i
. But as soon as the unit tests start, I get the same error.
t

Timothy Jones

05/31/2022, 4:05 PM
Do you see the binary download during the npm install?
what happens if you add
Copy code
file node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.88.83/pact/bin/pact-mock-service
to the build script?
this will tell you if the file is missing, is inappropriately html (indicating a login or proxy error), or is the binary and there's some other problem
note that
npm i
won't install the binary if it is missing but the package is there - so if you're caching your node_modules, it may stay missing
👍 1
a

Alex Maiburg

06/01/2022, 7:24 AM
Hey Timothy, sorry for the delay but I’m sitting in Germany.
Here is what Jenkins logs during
npm i
This is exactly the location where I dropped the tar.gz on Artifactory.
But when it comes to starting the pact tests node keeps giving me ENOENT errors.
m

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

06/01/2022, 7:29 AM
Thanks, no problems - we're equally at fault being in Australia 🤣
😃 1
Could please try the command Tim suggested above?
I believe you that the URL is correct, but we need to ensure it downloads correctly and has the correct contents
a

Alex Maiburg

06/01/2022, 8:01 AM
As Timothy suggested, I added the the command to the build script, but it failed. See screenshot.
m

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

06/01/2022, 8:14 AM
This might be a little painful, but could you please see what the zip file is e.g.
file <path/to/project>/standalone/linux-x64-1.88.83.tar.gz
👍 1
(obviously replace the correct bits)
a

Alex Maiburg

06/01/2022, 8:41 AM
Here is the file list I get after
rm -rf ./node_modules && npm i
Hmmm, the file owner is root. Why that? Maybe that’s the problem?
m

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

06/01/2022, 8:50 AM
It's Zero bytes, that would be the problem
a

Alex Maiburg

06/01/2022, 8:51 AM
Ok, I’m obviously blind…
😆 1
But why is that? How can I fix it?
🤷‍♂️ 1
m

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

06/01/2022, 8:52 AM
Are there any proxy settings (e.g. https_proxy)? If set, you might need to exclude artifactory. If not setz you might need to set them
a

Alex Maiburg

06/01/2022, 8:53 AM
Ok, I’ll check it
👍 1
Uffff, after what felt like 100 commits I came up with a simple script that did the trick…
Thanks for your time and help! I really appreciate it!!
t

Timothy Jones

06/01/2022, 11:42 AM
Hah! Well, I'm glad that worked. On a side note, I would recommend
npm
ci
in your CI- it will always install what is listed in package lock, which makes your build a bit more robust / repeatable. However, I don't think that was the issue you're facing
a

Alex Maiburg

06/01/2022, 11:48 AM
I changed it because I wanted to make sure that nothing gets cached. Surprisingly the install step is now even faster. But you’re right, I will undo it
👍 2
m

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

06/01/2022, 9:53 PM
I think the best way to solve this problem is to package all of the standalones into the library. This seems like a pretty painful upgrade experience! Did you test out the proxy environment variables? Is it possible that Artifactory is authenticated and the api client that does the post install is failinsg? What do the logs from
npm i
say?
a

Alex Maiburg

06/07/2022, 8:09 AM
No, I haven’t tested the proxy env variables. I was pretty happy that I could solve the problem with the build script. But I will definitely look into it. The logs during
npm i
weren’t very helpful. All it says ist that the regarding file is missing.
👍 1