Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camouflage fails on a GET request to /pets endpoint for a consecutive call (docker image: shubhendumadhukar/camouflage:latest) #255

Open
AdisRS opened this issue Nov 7, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@AdisRS
Copy link

AdisRS commented Nov 7, 2024

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:

  1. 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:

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" }
]
  1. Folder Structure Camouflage UI > Home > mocks > pets > GET.mock
  2. Error Stack Trace
Flow:
	1. 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 


	2. 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 (<anonymous>)
	   2024-11-07     at Validation.validateRequest (/usr/local/lib/node_modules/camouflage-server/dist/validation/index.js:63:40)
	   2024-11-07     at GlobalController.<anonymous> (/usr/local/lib/node_modules/camouflage-server/dist/routes/GlobalController.js:47:39)
	   2024-11-07     at Generator.next (<anonymous>)
	   2024-11-07     at /usr/local/lib/node_modules/camouflage-server/dist/routes/GlobalController.js:8:71
	   2024-11-07     at new Promise (<anonymous>)
	   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)
@AdisRS
Copy link
Author

AdisRS commented Nov 7, 2024

This might be the fix/related?: Bugfix: Change the default schema URL for petstore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants