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

TypeError: Cannot read property 'statusCode' of undefined #281

Closed
dimm999 opened this issue Feb 8, 2017 · 3 comments
Closed

TypeError: Cannot read property 'statusCode' of undefined #281

dimm999 opened this issue Feb 8, 2017 · 3 comments
Labels

Comments

@dimm999
Copy link

dimm999 commented Feb 8, 2017

Bug Report

I have read:

I am using the latest version of the library.

Expected Behavior

Im trying that bot working 24/7 and not show not expected errors.

Actual Behavior

Unhandled rejection TypeError: Cannot read property 'statusCode' of undefined
    at request.catch.err (D:\tg_bot\node_modules\node-telegram-bot-api\src\telegramPolling.js:148:25)
    at tryCatcher (D:\tg_bot\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (D:\tg_bot\node_modules\bluebird\js\release\promise.js:510:31)
    at Promise._settlePromise (D:\tg_bot\node_modules\bluebird\js\release\promise.js:567:18)
    at Promise._settlePromise0 (D:\tg_bot\node_modules\bluebird\js\release\promise.js:612:10)
    at Promise._settlePromises (D:\tg_bot\node_modules\bluebird\js\release\promise.js:687:18)
    at Async._drainQueue (D:\tg_bot\node_modules\bluebird\js\release\async.js:133:16)
    at Async._drainQueues (D:\tg_bot\node_modules\bluebird\js\release\async.js:143:10)
    at Immediate.Async.drainQueues (D:\tg_bot\node_modules\bluebird\js\release\async.js:17:14)
    at runCallback (timers.js:651:20)
    at tryOnImmediate (timers.js:624:5)
    at processImmediate [as _immediateCallback] (timers.js:596:5)

Steps to reproduce the Behavior

$ node -v
v7.4.0
$ npm -v
4.0.5

Windows 10 - 64bit - if it important.

package.json:

{
  "name": "tg_bot",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "mysql": "^2.13.0",
    "node-telegram-bot-api": "^0.26.0",
    "request": "^2.79.0"
  }
}
@the-AjK
Copy link

the-AjK commented Feb 8, 2017

Almost the same here:

Unhandled rejection TypeError: Cannot read property 'statusCode' of undefined
data:    index.js:10692 -     at request.catch.err (node_modules/node-telegram-bot-api/src/telegramPolling.js:148:25)
data:    index.js:10692 -     at runCallback (timers.js:649:20)
data:    index.js:10692 -     at tryOnImmediate (timers.js:622:5)
data:    index.js:10692 -     at processImmediate [as _immediateCallback] (timers.js:594:5)
data:    index.js:10692 - From previous event:
data:    index.js:10692 -     at TelegramBotPolling._getUpdates (node_modules/node-telegram-bot-api/src/telegramPolling.js:147:13)
data:    index.js:10692 -     at TelegramBotPolling._polling (node_modules/node-telegram-bot-api/src/telegramPolling.js:98:8)
data:    index.js:10692 -     at Timeout._pollingTimeout.setTimeout [as _onTimeout] (node_modules/node-telegram-bot-api/src/telegramPolling.js:117:56)
data:    index.js:10692 -     at ontimeout (timers.js:365:14)
data:    index.js:10692 -     at tryOnTimeout (timers.js:237:5)
data:    index.js:10692 -     at Timer.listOnTimeout (timers.js:207:5)

Linux 3.14.79 armv7l GNU/Linux
node 6.9.5
npm 3.10.9
node-telegram-bot 0.26.0

@GochoMugo GochoMugo added the bug label Feb 8, 2017
GochoMugo added a commit that referenced this issue Feb 8, 2017
Bug:

  On certain errors, during polling, cause the following error to be
  thrown:

    TypeError: Cannot read property 'statusCode' of undefined

  This is caused when we try to access the 'response' property on
  the error object in the error handler (`catch(error)`). It goes
  missing when the error was fatal, for example, network error, thus
  no server response available.

References:

  * Issue #281:  #281
  * Reported-by: @dimawebmaker
@GochoMugo
Copy link
Collaborator

Just pushed a fix for this in commit 7e4cadb514346f1fc7262fb445363b9ab9beeec2. Please try it out and let us know of the results.

GochoMugo added a commit that referenced this issue Feb 10, 2017
Added:

1. Add constructor options:
  * (#243) `options.polling.params` (by @GochoMugo, requested-by @sidelux)
1. Add methods:
  * (#74) *TelegramBot#removeReplyListener()* (by @githugger)
1. (#283) Add proper error handling (by @GochoMugo)
1. (#272) Add health-check endpoint (by @mironov)
  * `options.webHook.healthEndpoint`
1. (#152) Add test for TelegramBot#sendDocument() using 'fileOpts'
   param (by @evolun)
1. Document `options.webHook.host` (by @GochoMugo)
1. (#264) Add Bot API version to README (by @kamikazechaser)
1. Add examples:
  - (#271) WebHook on Heroku (by @TheBeastOfCaerbannog)
  - (#274) WebHook on Zeit Now (by @ferrari)

Changed:

1. (#147) Use *String#indexOf()*, instead of *RegExp#test()*, to
   find token in webhook request (by @AVVS)

Fixed:

* Fix bug:
  - (#275, #280) fix es6 syntax error on Node.js v4.x (by @CrazyAbdul)
  - (#276) promise.warning from `request-promise` (by @GochoMugo,
    reported-by @preco21)
  - (#281) fix handling error during polling (by @GochoMugo,
    reported-by @dimawebmaker)
  - (#284) fix error during deletion of already-set webhook, during
    polling (by @GochoMugo, reported-by @dcparga)
1. Fix links in documentation (by @Ni2c2k)
@GochoMugo
Copy link
Collaborator

Fixed in v0.27.0.

Thanks @dimawebmaker and @the-AjK for your time and effort in fixing this bug.

N-Agency-member pushed a commit to N-Agency-member/TelegramBot-API-Node.js- that referenced this issue Sep 3, 2024
Bug:

  On certain errors, during polling, cause the following error to be
  thrown:

    TypeError: Cannot read property 'statusCode' of undefined

  This is caused when we try to access the 'response' property on
  the error object in the error handler (`catch(error)`). It goes
  missing when the error was fatal, for example, network error, thus
  no server response available.

References:

  * Issue #281:  yagop/node-telegram-bot-api#281
  * Reported-by: @dimawebmaker
passion-27 added a commit to passion-27/node-telegram-bot that referenced this issue Oct 2, 2024
Bug:

  On certain errors, during polling, cause the following error to be
  thrown:

    TypeError: Cannot read property 'statusCode' of undefined

  This is caused when we try to access the 'response' property on
  the error object in the error handler (`catch(error)`). It goes
  missing when the error was fatal, for example, network error, thus
  no server response available.

References:

  * Issue #281:  yagop/node-telegram-bot-api#281
  * Reported-by: @dimawebmaker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants