Hi, I updated all pact related packages in Angular...
# pact-js
a
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
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
Hi Matt, thanks for your quick response. Yes, there’s definitely a proxy involved. I will look into it and let you know.
m
👍👍
a
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
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
Yes, it contains the standalone zip file.
m
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
Yes, I will upload it to Artifactory and reference it explicitly in the package.json
👍 1
m
For clarity, it’s still possible that the proxy can intercept the request to Artifactory
a
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
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
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
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
As Timothy suggested, I added the the command to the build script, but it failed. See screenshot.
m
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
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
It's Zero bytes, that would be the problem
a
Ok, I’m obviously blind…
😆 1
But why is that? How can I fix it?
🤷‍♂️ 1
m
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
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
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
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
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
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