node-easymock icon indicating copy to clipboard operation
node-easymock copied to clipboard

easymock server crashes on cancelled requests

Open sascha-haenlein opened this issue 7 years ago • 0 comments

I was working on cancelling an open request and recognized that my easymock server always crashes with the following message when request gets cancelled:

_http_outgoing.js:492
    throw new Error('"value" required in setHeader("' + name + '", value)');
    ^

Error: "value" required in setHeader("x-forwarded-for", value)
    at validateHeader (_http_outgoing.js:492:11)
    at ClientRequest.setHeader (_http_outgoing.js:501:3)
    at new ClientRequest (_http_client.js:173:14)
    at Object.request (http.js:38:10)
    at exports.HttpProxy.HttpProxy.proxyRequest (E:\Projects\amino-dat-online\node_modules\easymock\node_modules\http-proxy\lib\node-http-proxy\http-proxy.js:247:39)
    at exports.RoutingProxy.RoutingProxy.proxyRequest (E:\Projects\amino-dat-online\node_modules\easymock\node_modules\http-proxy\lib\node-http-proxy\routing-proxy.js:239:9)
    at Timeout._onTimeout (E:\Projects\amino-dat-online\node_modules\easymock\lib\easymock.js:214:15)
    at ontimeout (timers.js:475:11)
    at tryOnTimeout (timers.js:310:5)
    at Timer.listOnTimeout (timers.js:270:5)

That is how it can be caused:

mockserver config.json:

{
	"cors": true,
	"jsonp": false,
	"simulated-lag": 5000,
	"variables": {
	},
	"routes": [
	]
}

within any component:

let subject = new Subject<true>();

this.http.get('http://localhost:3000/mocks/data', {responseType: 'json'})
	.takeUntil(subject)
	.subscribe(
		(data) =>{
			this.responseData = data;
		},
		(err) =>{
		});

setTimeout(()=>{
	subject.next(true);
}, 1000);

sascha-haenlein avatar Feb 21 '18 13:02 sascha-haenlein