Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maximum call stack size exceeded #52

Closed
arcturial opened this issue Jul 20, 2016 · 6 comments
Closed

Maximum call stack size exceeded #52

arcturial opened this issue Jul 20, 2016 · 6 comments

Comments

@arcturial
Copy link
Collaborator

Started receiving this error once I upgraded to 0.1.1

ERROR RangeError: Maximum call stack size exceeded
  at Object.stringify (native)
  at TelegramBot.request (/home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot-telegram/node_modules/telegrambot/lib/telegrambot.js:75:53)
  at TelegramBot.invoke (/home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot-telegram/node_modules/telegrambot/lib/telegrambot.js:95:32)
  at /home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot-telegram/src/telegram.coffee:143:14
  at Telegram.apiSend (/home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot-telegram/src/telegram.coffee:150:5)
  at Telegram.reply (/home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot-telegram/src/telegram.coffee:179:6)
  at /home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot/src/response.coffee:82:7
  at allDone (/home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot/src/middleware.coffee:44:37)
  at /home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot/node_modules/async/lib/async.js:274:13
  at Object.async.eachSeries (/home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot/node_modules/async/lib/async.js:142:20)
  at Object.async.reduce (/home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot/node_modules/async/lib/async.js:268:15)
  at /home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot/src/middleware.coffee:49:13
  at nextTickCallbackWith0Args (node.js:420:9)
  at process._tickCallback (node.js:349:13)

[RangeError: Maximum call stack size exceeded]

Haven't had time to debug in detail yet, rolling back to 0.1.0 solved the problem...so I am assuming it's something in the new release.

@lukefx
Copy link
Owner

lukefx commented Jul 20, 2016

@arcturial strange...my bot is running with 0.1.1 for a while and I never seen this error...
By looking at the code the exception is thrown at 143 and 150, where we split messages in chunks recursively...can you try to set HUBOT_LOG_LEVEL=debug for a few days?

@arcturial
Copy link
Collaborator Author

I shall do that

@slackerzz
Copy link

i have the same problems of @arcturial
i found that after removing

res.envelope.telegram = {
  parse_mode: 'HTML',
  reply_markup: {
    keyboard: [['option1', 'option2']]
  }
};

my bot works again.

Before the error was:

[Tue Jul 26 2016 01:01:35 GMT+0200 (CEST)] DEBUG Message 'bot command' matched regex //command/i/; listener.options = { id: null }
[Tue Jul 26 2016 01:01:35 GMT+0200 (CEST)] DEBUG Executing listener callback for Message 'bot command'
[Tue Jul 26 2016 01:01:36 GMT+0200 (CEST)] DEBUG Message length: 90
[Tue Jul 26 2016 01:01:36 GMT+0200 (CEST)] DEBUG Message parts: 1
[Tue Jul 26 2016 01:01:36 GMT+0200 (CEST)] ERROR RangeError: Maximum call stack size exceeded
    at Object.stringify (native)
    at TelegramBot.request (/bot/node_modules/telegrambot/lib/telegrambot.js:75:53)
    at TelegramBot.invoke (/bot/node_modules/telegrambot/lib/telegrambot.js:95:32)
    at send (/bot/node_modules/hubot-telegram/src/telegram.coffee:143:9, <js>:165:28)
    at Telegram.apiSend (/bot/node_modules/hubot-telegram/src/telegram.coffee:150:5, <js>:171:14)
    at Telegram.send (/bot/node_modules/hubot-telegram/src/telegram.coffee:160:5, <js>:189:19)
    at runAdapterSend (/bot/node_modules/hubot/src/response.coffee:82:34, <js>:87:50)
    at allDone (/bot/node_modules/hubot/src/middleware.coffee:44:37, <js>:34:16)
    at /bot/node_modules/async/lib/async.js:274:13
    at Object.async.eachSeries (/bot/node_modules/async/lib/async.js:142:20)
    at Object.async.reduce (/bot/node_modules/async/lib/async.js:268:15)
    at /bot/node_modules/hubot/src/middleware.coffee:49:7, <js>:37:22
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

@manoamaro
Copy link
Contributor

It's happening when we put any extra params to res.envelope.telegram. Starting at line 72 (telegram.coffee), there is this method toString(object) that is called only when there is any extra.

    toString = (object) ->
      result = {}

      try
        for key in Object.keys(object)
          result[key] = toString(object[key])
      catch e
        result = "" + object;

      return result

    if extra?
      extra = toString(extra)
...

Not sure if it should work the same as JSON.stringify(obj), but actually it's returning a huge recursive object. The telegrambot already parses this extra to string using JSON.stringify(obj) (where the error occurs), so I think this code is not necessary anymore. I can submit a PR to remove this. Already tested here, and worked.

@lukefx
Copy link
Owner

lukefx commented Jul 29, 2016

Oh ok, perfect if you send a PR I will test it and merge it right away...

Am Freitag, 29. Juli 2016 schrieb Manoel de A.L. Amaro :

It's happening when we put any extra params to res.envelope.telegram.
Starting at line 72
https://github.com/lukefx/hubot-telegram/blob/master/src/telegram.coffee#L72
(telegram.coffee), there is this method toString(object) that is called
only when there is any extra.

toString = (object) ->
  result = {}

  try
    for key in Object.keys(object)
      result[key] = toString(object[key])
  catch e
    result = "" + object;

  return result

if extra?
  extra = toString(extra)

...

Not sure if it should work the same as JSON.stringify(obj), but actually
it's returning a huge recursive object. The telegrambot already parses this
extra to string using JSON.stringify(obj) (where the error occurs), so I
think this code is not necessary anymore. I can submit a PR to remove this.
Already tested here, and worked.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#52 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABwzsA04dQ110vSfcG1zW7F3dxD7b3rks5qaTMCgaJpZM4JQoJF
.

@arcturial
Copy link
Collaborator Author

Nice catch, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants