2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-29 05:17:41 +00:00

src/telegram: Use $NTBA_FIX_319 to apply fix for #319

Notes:

  The permanent fix introduces backwards-incompatible changes, which
  require a major version bump. Until we release v1,
  environment variable `${NTBA_FIX_319}` can be used to apply
  the fix.

References:

  * BR: https://github.com/yagop/node-telegram-bot-api/issues/319
This commit is contained in:
GochoMugo 2017-08-25 18:51:51 +03:00
parent ef48af49f5
commit f4f015a621
No known key found for this signature in database
GPG Key ID: 7B6A01CB57AA39E4

View File

@ -50,24 +50,26 @@ const _deprecatedMessageTypes = [
]; ];
// Enable Promise cancellation. if (!process.env.NTBA_FIX_319) {
try { // Enable Promise cancellation.
const msg = try {
'Automatic enabling of cancellation of promises is deprecated.\n' + const msg =
'In the future, you will have to enable it yourself.\n' + 'Automatic enabling of cancellation of promises is deprecated.\n' +
'See https://github.com/yagop/node-telegram-bot-api/issues/319.'; 'In the future, you will have to enable it yourself.\n' +
deprecate(msg); 'See https://github.com/yagop/node-telegram-bot-api/issues/319.';
Promise.config({ deprecate(msg);
cancellation: true, Promise.config({
}); cancellation: true,
} catch (ex) { });
/* eslint-disable no-console */ } catch (ex) {
const msg = /* eslint-disable no-console */
'error: Enabling Promise cancellation failed.\n' + const msg =
' Temporary fix is to load/require this library as early as possible before using any Promises.'; 'error: Enabling Promise cancellation failed.\n' +
console.error(msg); ' Temporary fix is to load/require this library as early as possible before using any Promises.';
throw ex; console.error(msg);
/* eslint-enable no-console */ throw ex;
/* eslint-enable no-console */
}
} }