I'm trying to use the pact standalone tools, mainl...
# pact-js
t
I'm trying to use the pact standalone tools, mainly pact-broker, but I'm not getting any output whatsoever, but also no error. I tried • Running it on Powershell Directly • Running it as an NPM Script • Piping the output to a file (is empty) • Checking the response code (is always 0) • Trying other standalone tools (pact-mock-server) • Adding --verbose • Rebooting • Using obviously wrong invocations, even just
pact-broker
and
npx pact-broker
, no change What might I be doing wrong?
Deleting the node_modules folder at least breaks the invocation (command not found)
After running
npm i
, I'm back to no output again.
I do get output, when executing the .bat file from the terminal directly
m
What OS/arch are you on. How are you installing the tools?
t
windows 11. Tools are installed with npm package @pact-foundation/pact
m
Have you tried downloading them separately? I wonder if it's something to do with how npm packages it or if it's an AV software interfering etc
t
Have you tried downloading them separately?
Not sure exactly, what you mean by that, tried global install with npm (Volta under the hood), no success. Installed binaries as described in https://github.com/pact-foundation/pact-ruby-standalone/releases/tag/v2.4.2 (also realized that the installation guide assumes unzip is available on windows, which wasn't the case for me, so I unzipped manually), those work fine, but I can also call the binaries installed by the npm packages without issues (by referencing the bat file, instead of using npx). So I'm fairly sure that this is related to how npm calls the bat files. This also seems to be bat-specfic, as the npx invocation works just fine on my macos machine.
m
Yep, that’s what I meant - download the standalone tools outside of npm.
Interesting that the
.bat
files work on their own - the npm packages should be calling the
.bat
files, not the shims.
It’s possible the OS detection is not working correctly: https://github.com/pact-foundation/pact-js-core/blob/master/src/pact-environment.ts#L8
t
Ran a debug session with VSCode's JavaScript Debug Terminal. Platform detection is working fine. I also extracted the generated binary path, if I enter that into the terminal I get output. However, I noticed that if I run past the childProcessSpawn, the status is null. So maybe Node fails to launch the process nevertheless?
From the node documentation:
modified the binary to get the signal as well, but it is null as well
oh yeah, because windows doesn't have signals
just logged the whole object returned by childprocess. The
error
property is set and reports
Copy code
error: Error: spawnSync T:\he\path\to\my\project\node_modules\@pact-foundation\pact-core\standalone\windows-x64-2.4.2\pact\bin\pact-broker.bat EINVAL
      at Object.spawnSync (node:internal/child_process:1124:20)
      at Object.spawnSync (node:child_process:876:24)
      at Object.<anonymous> (T:\he\path\to\my\project\node_modules\@pact-foundation\pact-core\bin\pact-broker.js:9:29)
      at Module._compile (node:internal/modules/cjs/loader:1369:14)
      at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
      at Module.load (node:internal/modules/cjs/loader:1206:32)
      at Module._load (node:internal/modules/cjs/loader:1022:12)
      at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
      at node:internal/main/run_main_module:28:49
m
ha! Good debugging sir. Mind creating an issue over at https://github.com/pact-foundation/pact-js-core/issues/new?
…even better, a PR! It looks like a fairly straightforward fix if I read that correctly
t
Yeah, but while add it I would also like to error logging to improve debugging in the future.
👍 1
PR is ready for review
🙌 1
m
I’ve just approved the run now, thanks for this!