3scale-labs / 3scale_ws_api_for_nodejs

3scale is an API Infrastructure service which handles API Keys, Rate Limiting, Analytics, Billing Payments and Developer Management. Includes a configurable API dashboard and developer portal CMS. More product stuff at http://www.3scale.net/, support information at http://support.3scale.net/.
http://www.3scale.net
MIT License
22 stars 13 forks source link

RangeError when running tests #18

Closed MWers closed 9 years ago

MWers commented 9 years ago

When running tests, I received the following error:

RangeError: Maximum call stack size exceeded

This error would occur every time I ran tests but it would occur at a different point in the tests. The following two examples were run consecutively 10 seconds apart:

$ TEST_3SCALE_PROVIDER_KEY=[redacted] TEST_3SCALE_APP_ID=[redacted] TEST_3SCALE_APP_KEY=[redacted] ./node_modules/.bin/vows test/* --spec

♢ Basic test for the 3Scale::AuthorizeResponse

  A authorize_response Should
    ✓ have a add_usage_report method
    ✓ can push a new UsageReport

♢ Basic test for the 3Scale::Client

    - The oauth_authorize method should
  A client
    ✓ should throw an exception if init without provider_key
    ✓ should have an default host
    ✓ can change the default host
    ✓ should have an authorize method
    ✓ should throw an exception if authorize method is called without :app_id
    ✓ should have an oauth_authorize method
    ✓ should throw an exception if oauth_authorize method is called without :app_id
    ✓ should have an authorize_with_user_key method
    ✓ should throw an exception if authorize_with_user_key is called without :user_key
    ✓ should have an authrep method
    ✓ should throw an exception if authrep called without :app_id
    ✓ should have an authrep_with_user_key method
    ✓ should throw an exception if authrep_with_user_key is called without :user_key
  The Event Emitter
    ✓ call the callback with a error response if app_id was wrong
  In the transaction method should
    ✓ give a success response with the correct params

✗ Errored » callback not fired
    in The authorize method should
    in Basic test for the 3Scale::Client
    in test/client_test.js
✗ Errored » callback not fired
    in Request headers in authorize calls
    in Basic test for the 3Scale::Client
    in test/client_test.js
✗ Errored » callback not fired
    in Request headers in report calls
    in Basic test for the 3Scale::Client
    in test/client_test.js
✗ Errored » 17 honored ∙ 1 errored ∙ 1 pending ∙ 5 dropped

RangeError: Maximum call stack size exceeded
$ TEST_3SCALE_PROVIDER_KEY=[redacted] TEST_3SCALE_APP_ID=[redacted] TEST_3SCALE_APP_KEY=[redacted] ./node_modules/.bin/vows test/* --spec

♢ Basic test for the 3Scale::AuthorizeResponse

  A authorize_response Should
    ✓ have a add_usage_report method
    ✓ can push a new UsageReport

♢ Basic test for the 3Scale::Client

    - The oauth_authorize method should
  A client
    ✓ should throw an exception if init without provider_key
    ✓ should have an default host
    ✓ can change the default host
    ✓ should have an authorize method
    ✓ should throw an exception if authorize method is called without :app_id
    ✓ should have an oauth_authorize method
    ✓ should throw an exception if oauth_authorize method is called without :app_id
    ✓ should have an authorize_with_user_key method
    ✓ should throw an exception if authorize_with_user_key is called without :user_key
    ✓ should have an authrep method
    ✓ should throw an exception if authrep called without :app_id
    ✓ should have an authrep_with_user_key method
    ✓ should throw an exception if authrep_with_user_key is called without :user_key
  Request headers in authorize calls
    ✓ should include the 3scale user agent
    ✓ should include the default 3scale host
  Request headers in report calls
    ✓ should include the 3scale user agent
    ✓ should include the default 3scale host
  In the transaction method should
    ✓ give a success response with the correct params
  The Event Emitter
    ✓ call the callback with a error response if app_id was wrong

✗ Errored » callback not fired
    in The authorize method should
    in Basic test for the 3Scale::Client
    in test/client_test.js
✗ Errored » 21 honored ∙ 1 errored ∙ 1 pending ∙ 1 dropped

RangeError: Maximum call stack size exceeded

To fix this, I upgraded vows to the following in package.json:

"vows": "0.8.x"
mikz commented 9 years ago

Could you give us your nodejs version so we can try to reproduce it on travis?

MWers commented 9 years ago

Sure thing, please let me know if there's any other info I can give you:

$ node -v
v0.10.29
mikz commented 9 years ago

Do you have full stack trace? It passes fine on travis https://travis-ci.org/3scale/3scale_ws_api_for_nodejs/jobs/46478423 Anyway, I issued #19 that updates vows. But still would be nice to know why it failed for you.

MWers commented 9 years ago

It doesn't print a stack trace on error. I'm running it now with the --trace option and will post that when it's complete. Or is there a better way to isolate it?

MWers commented 9 years ago

I've posted the results of running tests with the --trace option here:

https://www.dropbox.com/s/oksjkkiht1kmv6f/3scale-node-test.trace.gz?dl=0

Hopefully I've properly scrubbed it of my TEST_3SCALE_PROVIDER_KEY. :-) I used the TEST_3SCALE_APP_ID and TEST_3SCALE_APP_KEY values that are in the .travis.yml file so I left those in the trace.

I'm fairly new to Node.js so it's hard for me to tell exactly what's going on but it looks like it recursively iterates over the section of the test at lines 100-101 of client_test.coffee until it hits the stack size max.

https://github.com/3scale/3scale_ws_api_for_nodejs/blob/master/test/client_test.coffee#L100

Incidentally, after I upgraded vows to 0.8.x, that section of the tests still fails for me but not with the RangeError:

$ TEST_3SCALE_PROVIDER_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx TEST_3SCALE_APP_ID=4d4b20b9 TEST_3SCALE_APP_KEY=ecce202ecc2eb8dc7a499c34a34d5987 ./node_modules/.bin/vows test/* --spec

  ♢ Basic test for the 3Scale::AuthorizeResponse

  A authorize_response Should
    ✓ have a add_usage_report method
    ✓ can push a new UsageReport

  ♢ Basic test for the 3Scale::Client

    - The oauth_authorize method should
  A client
    ✓ should throw an exception if init without provider_key
    ✓ should have an default host
    ✓ can change the default host
    ✓ should have an authorize method
    ✓ should throw an exception if authorize method is called without :app_id
    ✓ should have an oauth_authorize method
    ✓ should throw an exception if oauth_authorize method is called without :app_id
    ✓ should have an authorize_with_user_key method
    ✓ should throw an exception if authorize_with_user_key is called without :user_key
    ✓ should have an authrep method
    ✓ should throw an exception if authrep called without :app_id
    ✓ should have an authrep_with_user_key method
    ✓ should throw an exception if authrep_with_user_key is called without :user_key
  The authorize method should
    ✗ call the callback with the AuthorizeResponse
        » expected true, got false // /Users/matt/Dropbox/Projects/Surfline/GitHub/3scale_ws_api_for_nodejs/test/client_test.coffee:101
  In the transaction method should
    ✓ give a success response with the correct params
  The Event Emitter
    ✓ call the callback with a error response if app_id was wrong
  Request headers in report calls
    ✓ should include the 3scale user agent
    ✓ should include the default 3scale host
  Request headers in authorize calls
    ✓ should include the 3scale user agent
    ✓ should include the default 3scale host

  ♢ Basic test for the 3Scale::Response

  A response Should
    ✓ have a success method
    ✓ have a code & message null after a success
    ✓ have a error method
    ✓ have a custom code and message after error
    ✓ have a custom code and null message after error
    ✓ have a is_success method
    ✓ be true after a call to success method
    ✓ be false after a error method

✗ Broken » 29 honored ∙ 1 broken ∙ 1 pending (0.605s)

Thanks!