-
-
Notifications
You must be signed in to change notification settings - Fork 354
Description
I am getting the following error:
2025-09-04T16:20:46.363404Z ERROR ThreadId(02) pact_ffi::mock_server: Failed to start mock server - Could not start server: error creating server listener: Address already in use (os error 98)
Causing me to also get this other error (which is why I'm reporting this here, lemme know if this is the wrong repo):
pact-core@16.1.0: !!!!!!!!! PACT CRASHED !!!!!!!!!
The pact consumer core returned false at 'withResponseBody'. This
should only happen if the core methods were invoked out of order
This is almost certainly a bug in pact-js-core. It would be great if you could
open a bug report at: https://github.com/pact-foundation/pact-js-core/issues
so that we can fix it.
There is additional debugging information above. If you open a bug report,
please rerun with logLevel: 'debug' set in the VerifierOptions, and include the
full output.
SECURITY WARNING: Before including your log in the issue tracker, make sure you
have removed sensitive info such as login credentials and urls that you don't want
to share with the world.
We're sorry about this!
I am currently using jest with --runInBand
, so it doesn't seem to be caused by jest's parallelism.
I also have a wrapper for writing these interactions:
import { Pact } from "@pact-foundation/pact";
import type { DataProvider } from "@refinedev/core";
import dataProvider from "@refinedev/simple-rest";
import path from "node:path";
const provider = new Pact({
dir: path.resolve(process.cwd(), "pacts"),
consumer: "simple-rest-client",
provider: "backend",
});
// @ts-ignore
let providerUrl: string = null;
beforeAll(async () =>
provider.setup().then(({ port }) => {
providerUrl = `http://localhost:${port}`;
}),
);
export function testInteraction(
name: string,
block: (provider: Pact, consumer: DataProvider) => Promise<void>,
) {
test(name, async () => {
const consumer = dataProvider(providerUrl);
await block(provider, consumer);
await provider.verify();
});
}
Which you can then use sort of like this:
testInteraction("user list", async (provider, consumer) => {
await provider.addInteraction({
state: "some state",
uponReceiving: "the request",
withRequest: {
method: "GET",
path: "/user",
},
willRespondWith: {
status: 200,
// ...etc
},
});
const { data } = await consumer.getList<IUser>({
resource: "user",
sorters: [{ field: "created_at", order: "asc" }],
});
assert(data);
});
Maybe my code is doing something wrong here?
Software versions
- OS: macos 15.6.1, but also reproducible in CI (Ubuntu 24.04)
- Pact Node version: ???
- Node Version: v24.7.0
- Other Versions:
"@pact-foundation/pact-core": "^16.0.0"
,"@pact-foundation/pact": "^15.0.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
- 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
My tests run without issue.
Actual behaviour
I get an address already in use error, even though netstat -tnpl
doesnt return anything when the tests aren't running.
Steps to reproduce
See above.
Relevant log files
It contains internal information so this won't be available.