Camouflage is a backend mocking tool for HTTP, gRPC, Websockets and Thrift protocols, which helps you carry out your front end prototyping, unit testing, functional/performance testing in silos, in absence of one or more Microservices/APIs.
Describe the bug
Camouflage errors with "Error: socket hang up" when sending a 2nd consecutive request to an endpoint.
Succeeds with 200 OK on the 1st GET request (tested via Postman) to "[localhost...]/pets",
but fails if a GET request is sent again to the same endpoint.
To Reproduce
Steps to reproduce the behavior:
Mock File Content
Note: It's actually the default endpoint "pets" that you have on Camouflage UI,
but any endpoint has the same behaviour/bug, content of GET.mock for pets follows:
Fails if a request is sent again to the same endpoint (GET "[localhost...]/pets")
camouflage logs show the following:
2024-11-07 /usr/local/lib/node_modules/camouflage-server/dist/validation/OpenApiAdapter.js:23
2024-11-07 const { paths } = this.document;
2024-11-07 ^
2024-11-07
2024-11-07 TypeError: Cannot destructure property 'paths' of 'this.document' as it is undefined.
2024-11-07 at OpenApiAdapter.findRoute (/usr/local/lib/node_modules/camouflage-server/dist/validation/OpenApiAdapter.js:23:17)
2024-11-07 at OpenApiAdapter.supportsRequest (/usr/local/lib/node_modules/camouflage-server/dist/validation/OpenApiAdapter.js:93:21)
2024-11-07 at /usr/local/lib/node_modules/camouflage-server/dist/validation/index.js:63:68
2024-11-07 at Array.filter ()
2024-11-07 at Validation.validateRequest (/usr/local/lib/node_modules/camouflage-server/dist/validation/index.js:63:40)
2024-11-07 at GlobalController. (/usr/local/lib/node_modules/camouflage-server/dist/routes/GlobalController.js:47:39)
2024-11-07 at Generator.next ()
2024-11-07 at /usr/local/lib/node_modules/camouflage-server/dist/routes/GlobalController.js:8:71
2024-11-07 at new Promise ()
2024-11-07 at __awaiter (/usr/local/lib/node_modules/camouflage-server/dist/routes/GlobalController.js:4:12)
2024-11-07
2024-11-07 Node.js v19.1.0
2024-11-07 warn: [117] Worker Stopped Thu Nov 07 2024 <----------------------- Worker dies :(
2024-11-07 info: CORS enabled for http://localhost:3000, http://localhost:3001, http://localhost:5000
2024-11-07
2024-11-07 info: [139] Worker started <----------------------- Worker alive again xD
2024-11-07 info: Handlebar helpers registration started
2024-11-07 warn: Code Injection is disabled. Helpers such as code, inject, pg, csv and functionalities such as external helpers, will not work.
2024-11-07 info: Handlebar helpers registration completed
2024-11-07 info: No middleware injection.
2024-11-07
2024-11-07 (node:139) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
2024-11-07 (Use node --trace-deprecation ... to show where the warning was created)
2024-11-07 info: Worker sharing HTTP server at http://localhost:8080 ⛳
Note:* After the failed request, the worker seems to restart
and the flow starts from the beginning with the same behaviour.
**Expected behavior**
When sending a GET request (via Postman) to "[localhost...]/pets"
it should return a 200 OK response each time, not only on an initial call.
**Desktop (please complete the following information):**
- OS: Windows 11 Pro (tested using Docker Desktop and a container with image: "shubhendumadhukar/camouflage:latest"
and "shubhendumadhukar/camouflage-filemanager:latest" for the camouflage UI)
- Browser Chrome
- Version 130.0.6723.117 (Official Build) (64-bit)
**Additional logs**
2024-11-07 info: [1] Master Started
2024-11-07 info: Cluster metrics server listening to 5555, metrics exposed on http://localhost:5555/metrics . Set a negative value for config.monitoring.port to enable monitoring
2024-11-07 info: CORS enabled for http://localhost:3000, http://localhost:3001, http://localhost:5000
2024-11-07 info: [29] Worker started
2024-11-07
2024-11-07 info: Handlebar helpers registration started
2024-11-07 warn: Code Injection is disabled. Helpers such as code, inject, pg, csv and functionalities such as external helpers, will not work.
2024-11-07 info: Handlebar helpers registration completed
2024-11-07 info: No middleware injection.
2024-11-07
2024-11-07 info: Worker sharing HTTP server at http://localhost:8080 ⛳
2024-11-07
2024-11-07 (node:1) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
2024-11-07 (Use node --trace-deprecation ... to show where the warning was created)
2024-11-07
2024-11-07 (node:29) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
2024-11-07 (Use node --trace-deprecation ... to show where the warning was created)
Describe the bug Camouflage errors with "Error: socket hang up" when sending a 2nd consecutive request to an endpoint. Succeeds with 200 OK on the 1st GET request (tested via Postman) to "[localhost...]/pets", but fails if a GET request is sent again to the same endpoint.
To Reproduce Steps to reproduce the behavior:
HTTP/1.1 200 OK Content-Type: application/json
[ { "id": 1, "name": "Rabbit" }, { "id": 2, "name": "Dog" }, { "id": 3, "name": "Cat" }, { "id": 4, "name": "Bird" } ]
Flow:
Succeeds with 200 OK (via Postman) on the 1st GET request to "[localhost...]/pets" but the camouflage logs show the following error:
2024-11-07 error: Couldn't load OpenApi validation schema https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.json, because: Error downloading https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.json 2024-11-07 HTTP ERROR 404
Fails if a request is sent again to the same endpoint (GET "[localhost...]/pets") camouflage logs show the following:
2024-11-07 /usr/local/lib/node_modules/camouflage-server/dist/validation/OpenApiAdapter.js:23 2024-11-07 const { paths } = this.document; 2024-11-07 ^ 2024-11-07 2024-11-07 TypeError: Cannot destructure property 'paths' of 'this.document' as it is undefined. 2024-11-07 at OpenApiAdapter.findRoute (/usr/local/lib/node_modules/camouflage-server/dist/validation/OpenApiAdapter.js:23:17) 2024-11-07 at OpenApiAdapter.supportsRequest (/usr/local/lib/node_modules/camouflage-server/dist/validation/OpenApiAdapter.js:93:21) 2024-11-07 at /usr/local/lib/node_modules/camouflage-server/dist/validation/index.js:63:68 2024-11-07 at Array.filter ()
2024-11-07 at Validation.validateRequest (/usr/local/lib/node_modules/camouflage-server/dist/validation/index.js:63:40)
2024-11-07 at GlobalController. (/usr/local/lib/node_modules/camouflage-server/dist/routes/GlobalController.js:47:39)
2024-11-07 at Generator.next ()
2024-11-07 at /usr/local/lib/node_modules/camouflage-server/dist/routes/GlobalController.js:8:71
2024-11-07 at new Promise ()
2024-11-07 at __awaiter (/usr/local/lib/node_modules/camouflage-server/dist/routes/GlobalController.js:4:12)
2024-11-07
2024-11-07 Node.js v19.1.0
2024-11-07 warn: [117] Worker Stopped Thu Nov 07 2024 <----------------------- Worker dies :(
2024-11-07 info: CORS enabled for http://localhost:3000, http://localhost:3001, http://localhost:5000
2024-11-07
2024-11-07 info: [139] Worker started <----------------------- Worker alive again xD
2024-11-07 info: Handlebar helpers registration started
2024-11-07 warn: Code Injection is disabled. Helpers such as code, inject, pg, csv and functionalities such as external helpers, will not work.
2024-11-07 info: Handlebar helpers registration completed
2024-11-07 info: No middleware injection.
2024-11-07
2024-11-07 (node:139) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
2024-11-07 (Use
node --trace-deprecation ...
to show where the warning was created) 2024-11-07 info: Worker sharing HTTP server at http://localhost:8080 ⛳Note:* After the failed request, the worker seems to restart and the flow starts from the beginning with the same behaviour.
2024-11-07 info: [1] Master Started 2024-11-07 info: Cluster metrics server listening to 5555, metrics exposed on http://localhost:5555/metrics . Set a negative value for config.monitoring.port to enable monitoring
2024-11-07 info: CORS enabled for http://localhost:3000, http://localhost:3001, http://localhost:5000 2024-11-07 info: [29] Worker started 2024-11-07 2024-11-07 info: Handlebar helpers registration started 2024-11-07 warn: Code Injection is disabled. Helpers such as code, inject, pg, csv and functionalities such as external helpers, will not work. 2024-11-07 info: Handlebar helpers registration completed 2024-11-07 info: No middleware injection. 2024-11-07 2024-11-07 info: Worker sharing HTTP server at http://localhost:8080 ⛳ 2024-11-07 2024-11-07 (node:1) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated. 2024-11-07 (Use
node --trace-deprecation ...
to show where the warning was created) 2024-11-07 2024-11-07 (node:29) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated. 2024-11-07 (Usenode --trace-deprecation ...
to show where the warning was created)