testinggospels / camouflage

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.
https://testinggospels.github.io/camouflage/
MIT License
278 stars 26 forks source link

File helper: Error: Can't set headers after they are sent. #229

Closed dagardner-nv closed 1 year ago

dagardner-nv commented 1 year ago

Describe the bug Using the file helper in 0.14.1 (works in 0.9) gives me this error:

Error: Can't set headers after they are sent.
    at SendStream.headersAlreadySent 

To Reproduce Steps to reproduce the behavior:

  1. Mock File Content
    
    HTTP/1.1 200 OK
    Content-Type: text/plain;charset=UTF-8

{{file path="../tests_data/filter_probs.jsonlines"}}

2. Folder Structure `mocks/api/v1/data-lines/GET.mock`
3. Error Stack Trace

2023-08-04 10:12:14 debug: Using new line as \n 2023-08-04 10:12:14 debug: Response Status set to 200 2023-08-04 10:12:14 debug: Headers Set Content-Type: text/plain;charset=UTF-8 2023-08-04 10:12:14 debug: HTTP GET /api/v1/data-lines :: Query Parameters: {} | Request Headers {"host":"localhost:8080","user-agent":"curl/8.1.2","accept":"/"} | Request Body {} Error: Can't set headers after they are sent. at SendStream.headersAlreadySent (/home/dagardner/work/conda/envs/morpheus/lib/node_modules/camouflage-server/node_modules/send/index.js:386:13) at SendStream.send (/home/dagardner/work/conda/envs/morpheus/lib/node_modules/camouflage-server/node_modules/send/index.js:613:10) at onstat (/home/dagardner/work/conda/envs/morpheus/lib/node_modules/camouflage-server/node_modules/send/index.js:725:10) at FSReqCallback.oncomplete (node:fs:209:5)



**Expected behavior**
Return file contents

**Desktop (please complete the following information):**
 - OS: Debian Bullseye
 - Browser curl
 - Version 8.1.2

**Additional context**
[camouflage.log](https://github.com/testinggospels/camouflage/files/12263027/camouflage.log)
https://github.com/dagardner-nv/Morpheus/blob/david-rest-source-sink/tests/tests_data/filter_probs.jsonlines
github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 0.14.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: