strongloop / strong-remoting

Communicate between objects in servers, mobile apps, and other servers.
www.strongloop.com
Other
105 stars 93 forks source link

Infinite recursion in httpCoerce with v2.23.0 #268

Closed AaronM04 closed 8 years ago

AaronM04 commented 8 years ago

Hi, so I did an npm install without upgrading my loopback version, and it bumped loopback's strong-reporting dependency from v2.22.0 to the next minor version. Now I get an infinite recursion:

RangeError: Maximum call stack size exceeded
    at Object.hasOwnProperty (native)
    at coerceString (/Users/[censored]/git/[censored]/node_modules/loopback/node_modules/strong-remoting/lib/http-coerce.js:56:17)
    at httpCoerce (/Users/[censored]/git/[censored]/node_modules/loopback/node_modules/strong-remoting/lib/http-coerce.js:35:13)
    at httpCoerce (/Users/[censored]/git/[censored]/node_modules/loopback/node_modules/strong-remoting/lib/http-coerce.js:31:20)
    at httpCoerce (/Users/[censored]/git/[censored]/node_modules/loopback/node_modules/strong-remoting/lib/http-coerce.js:31:20)
    at httpCoerce (/Users/[censored]/git/[censored]/node_modules/loopback/node_modules/strong-remoting/lib/http-coerce.js:31:20)
    at httpCoerce (/Users/[censored]/git/[censored]/node_modules/loopback/node_modules/strong-remoting/lib/http-coerce.js:31:20)
    at httpCoerce (/Users/[censored]/git/[censored]/node_modules/loopback/node_modules/strong-remoting/lib/http-coerce.js:31:20)
    at httpCoerce (/Users/[censored]/git/[censored]/node_modules/loopback/node_modules/strong-remoting/lib/http-coerce.js:31:20)
    at httpCoerce (/Users/[censored]/git/[censored]/node_modules/loopback/node_modules/strong-remoting/lib/http-coerce.js:31:20)
    at httpCoerce (/Users/[censored]/git/[censored]/node_modules/loopback/node_modules/strong-remoting/lib/http-coerce.js:31:20)
    at httpCoerce (/Users/[censored]/git/[censored]/node_modules/loopback/node_modules/strong-remoting/lib/http-coerce.js:31:20)
    at httpCoerce (/Users/[censored]/git/[censored]/node_modules/loopback/node_modules/strong-remoting/lib/http-coerce.js:31:20)
    at httpCoerce (/Users/[censored]/git/[censored]/node_modules/loopback/node_modules/strong-remoting/lib/http-coerce.js:31:20)
    at httpCoerce (/Users/[censored]/git/[censored]/node_modules/loopback/node_modules/strong-remoting/lib/http-coerce.js:31:20)
    at httpCoerce (/Users/[censored]/git/[censored]/node_modules/loopback/node_modules/strong-remoting/lib/http-coerce.js:31:20)
AaronM04 commented 8 years ago

This is with a remote method configured as follows:

 user.remoteMethod "<snip>",
    http: { verb: "post", path: "/:id/<snip>/:fk" }
    accepts:[
      { arg: "id", type: "number", required: true }
      { arg: "fk", type: "number", required: true }
      { arg: "questions", type: "array[object]", required: true }
      { arg: "ctx", type: "object", required: true, http: (ctx) -> ctx }
    ]
    returns: { type: "object", root: true }

Could this have anything to do with the ctx argument (which is recursively defined)?

raymondfeng commented 8 years ago

I think ctx has circular references. It should be excluded from coercion.

raymondfeng commented 8 years ago

@STRML @bajtos We should exclude req, res, and ctx from coercion.

STRML commented 8 years ago

I agree, as I mentioned before, the patch was merged half-finished. 2.23.0 should not have been released.

STRML commented 8 years ago

See https://github.com/strongloop/strong-remoting/pull/265

bajtos commented 8 years ago

I apologise for the troubles. I am going to revert the patch that introduced this problem - see https://github.com/strongloop/strong-remoting/pull/269

bajtos commented 8 years ago

Should be fixed in v2.23.1.