pact-msw-adapter icon indicating copy to clipboard operation
pact-msw-adapter copied to clipboard

Endpoint returns 500 after updating to Node 20.15

Open twalshOG opened this issue 11 months ago • 0 comments

Software versions

Please provide at least OS and version of pact-js

  • OS: Ubuntu 22.04 and macOS 14 Arm64
  • Pact Node version: "@pactflow/pact-msw-adapter": "3.0.1"
  • Node Version: v20.16.0
  • Other Versions: Most versions above v20.16.0 (got as high as v22 and stopped checking at that point) - works on v21.7.3

Issue Checklist

Please confirm the following:

  • [x] I have upgraded to the latest
  • [x] I have the read the FAQs in the Readme
  • [x] I have triple checked, that there are no unhandled promises in my code
  • [x] I have set my log level to debug and attached a log file showing the complete request/response cycle
  • [x] For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem

Expected behaviour

The unit test would pass as MSW retuned the expected response

Actual behaviour

The unit test fails because MSW returns a 500 error.

Steps to reproduce

See: https://github.com/twalshOG/pact-msw-adapter-bug/actions/runs/12362599164 Basically just run with different node version.

Relevant log files

image Locally:

Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Rejection ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
AxiosError: Network Error
 ❯ XMLHttpRequest.handleError node_modules/axios/lib/adapters/xhr.js:110:14
 ❯ XMLHttpRequest.methodCall node_modules/@mswjs/interceptors/src/interceptors/XMLHttpRequest/XMLHttpRequestController.ts:194:20
 ❯ Proxy.<anonymous> node_modules/@mswjs/interceptors/src/utils/createProxy.ts:93:29
 ❯ XMLHttpRequestController.trigger node_modules/@mswjs/interceptors/src/interceptors/XMLHttpRequest/XMLHttpRequestController.ts:530:16
 ❯ XMLHttpRequestController.errorWith node_modules/@mswjs/interceptors/src/interceptors/XMLHttpRequest/XMLHttpRequestController.ts:484:10
 ❯ XMLHttpRequestController.xhrRequestController.onRequest node_modules/@mswjs/interceptors/src/interceptors/XMLHttpRequest/XMLHttpRequestProxy.ts:98:32
 ❯ processTicksAndRejections node:internal/process/task_queues:95:5
 ❯ Axios.request node_modules/axios/lib/core/Axios.js:45:41
 ❯ processTicksAndRejections node:internal/process/task_queues:95:5
 ❯ fetchData app/AnimalsTable.tsx:13:36
     11|   useEffect(() => {
     12|     const fetchData = async () => {
     13|         const animal: IAnimal[] = (await API.getAllAnimals())?.data;
       |                                    ^
     14|         setAnimal(animal);
     15|     };

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { description: undefined, number: undefined, fileName: undefined, lineNumber: undefined, columnNumber: undefined, config: { transitional: { silentJSONParsing: true, forcedJSONParsing: true, clarifyTimeoutError: false }, adapter: [ 'xhr', 'http', 'fetch' ], transformRequest: [ 'Function<transformRequest>' ], transformResponse: [ 'Function<transformResponse>' ], timeout: +0, xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, maxBodyLength: -1, env: { FormData: 'Function<FormData>', Blob: 'Function<Blob>' }, validateStatus: 'Function<validateStatus>', headers: { Accept: 'application/json, text/plain, */*', Authorization: 'Bearer 2024-12-16T21:48:40.114Z' }, method: 'get', url: 'http://localhost:3030/v2/animals' }, code: 'ERR_NETWORK', status: undefined }
This error originated in "tests/AnimalTable.pact.test.tsx" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "renders table with a peice of content and capture pact". It might mean one of the following:
- The error was thrown, while Vitest was running this test.
- If the error occurred after the test had been completed, this was the last documented test before it was thrown.

In GitHub pipeline

  [pact-msw-adapter] Checking request against url filters
    {
      urlString: 'http://127.0.0.1:3030/v2/animals',
      providerFilter: true,
      includeFilter: true,
      excludeFilter: true,
      matchIsAllowed: true
    }
    [pact-msw-adapter] Matching request
      [pact-msw-adapter] {"url":"http://127.0.0.1:3030/v2/animals"}
      Response: GET http://127.0.0.1:3030/v2/animals received 500 Unhandled Exception
......
Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.

⎯⎯⎯⎯ Unhandled Rejection ⎯⎯⎯⎯⎯
AxiosError: Request failed with status code 500
 ❯ settle node_modules/axios/lib/core/settle.js:19:12
 ❯ XMLHttpRequest.onloadend node_modules/axios/lib/adapters/xhr.js:59:7
 ❯ XMLHttpRequest.methodCall node_modules/@mswjs/interceptors/src/interceptors/XMLHttpRequest/XMLHttpRequestController.ts:[206](https://github.com/OpenGov/qce-skunkworks/actions/runs/12358460745/job/34489024716#step:5:207):20
 ❯ Proxy.<anonymous> node_modules/@mswjs/interceptors/src/utils/createProxy.ts:93:29
 ❯ XMLHttpRequestController.trigger node_modules/@mswjs/interceptors/src/interceptors/XMLHttpRequest/XMLHttpRequestController.ts:630:16
 ❯ finalizeResponse node_modules/@mswjs/interceptors/src/interceptors/XMLHttpRequest/XMLHttpRequestController.ts:420:12
 ❯ readNextResponseBodyChunk node_modules/@mswjs/interceptors/src/interceptors/XMLHttpRequest/XMLHttpRequestController.ts:436:11
 ❯ processTicksAndRejections node:internal/process/task_queues:95:5
 ❯ Axios.request node_modules/axios/lib/core/Axios.js:45:41
 ❯ processTicksAndRejections node:internal/process/task_queues:95:5
 ❯ fetchData app/AnimalsTable.tsx:13:36
     11|   useEffect(() => {
     12|     const fetchData = async () => {
     13|         const animal: IAnimal[] = (await API.getAllAnimals())?.data;
       |                                    ^
     14|         setAnimal(animal);
     15|     };

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { description: undefined, number: undefined, fileName: undefined, lineNumber: undefined, columnNumber: undefined, config: { transitional: { silentJSONParsing: true, forcedJSONParsing: true, clarifyTimeoutError: false }, adapter: [ 'xhr', 'http', 'fetch' ], transformRequest: [ 'Function<transformRequest>' ], transformResponse: [ 'Function<transformResponse>' ], timeout: +0, xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, maxBodyLength: -1, env: { FormData: 'Function<FormData>', Blob: 'Function<Blob>' }, validateStatus: 'Function<validateStatus>', headers: { Accept: 'application/json, text/plain, */*', Authorization: '***' }, method: 'get', url: 'http://127.0.0.1:3030/v2/animals' }, code: 'ERR_BAD_RESPONSE', status: 500 }

twalshOG avatar Dec 16 '24 22:12 twalshOG