haxetink / tink_web

Tinkerbell Web Framework
https://haxetink.github.io/tink_web
43 stars 14 forks source link

NodeJS JSON Stringify circular reference issue #127

Open tjrhodes opened 2 years ago

tjrhodes commented 2 years ago

Hi,

I've got a login script that used to work in a project I'm resurecting. I've got everything compiling using newer tink_web from haxelib. However when rejecting a promise containing an OutgoingResponse I'm getting a node error at runtime.

TypeError: Converting circular structure to JSON

The OutgoingResponse that causes the error does indeed contain a circulare reference:

{ header: { statusCode: 200, reason: 'OK', protocol: 'HTTP/1.1', fields: [] }, body: { retainCount: 0, value: { value: [Object] } } }

There value referes to itself which looks to be the cause of the problem. My OutgoingResponse is created like this:

var failedResponse = new OutgoingResponse(new ResponseHeader(200, "OK", null), 'false');

Any ideas? Will try the success side of the Promise in the auth script to see if it's response suffers a similar fate ;)

Cheers, Tom.

kevinresol commented 2 years ago

Please kindly provide a compilable snippet so we can reproduce and understand your problem. I guess you are somehow trying to jsonify a tink.io.Source