{"action":"created","issue":{"url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/issues/572","repository_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script","labels_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/issues/572/labels{/name}","comments_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/issues/572/comments","events_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/issues/572/events","html_url":"https://github.com/Azure/azure-webjobs-sdk-script/issues/572","id":170884224,"number":572,"title":"[Bug] [Node.js] Strange timeout fixed with a simple console.log (weird)","user":{"login":"yvele","id":4225430,"avatar_url":"https://avatars.githubusercontent.com/u/4225430?v=3","gravatar_id":"","url":"https://api.github.com/users/yvele","html_url":"https://github.com/yvele","followers_url":"https://api.github.com/users/yvele/followers","following_url":"https://api.github.com/users/yvele/following{/other_user}","gists_url":"https://api.github.com/users/yvele/gists{/gist_id}","starred_url":"https://api.github.com/users/yvele/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yvele/subscriptions","organizations_url":"https://api.github.com/users/yvele/orgs","repos_url":"https://api.github.com/users/yvele/repos","events_url":"https://api.github.com/users/yvele/events{/privacy}","received_events_url":"https://api.github.com/users/yvele/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":{"login":"christopheranderson","id":2252976,"avatar_url":"https://avatars.githubusercontent.com/u/2252976?v=3","gravatar_id":"","url":"https://api.github.com/users/christopheranderson","html_url":"https://github.com/christopheranderson","followers_url":"https://api.github.com/users/christopheranderson/followers","following_url":"https://api.github.com/users/christopheranderson/following{/other_user}","gists_url":"https://api.github.com/users/christopheranderson/gists{/gist_id}","starred_url":"https://api.github.com/users/christopheranderson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christopheranderson/subscriptions","organizations_url":"https://api.github.com/users/christopheranderson/orgs","repos_url":"https://api.github.com/users/christopheranderson/repos","events_url":"https://api.github.com/users/christopheranderson/events{/privacy}","received_events_url":"https://api.github.com/users/christopheranderson/received_events","type":"User","site_admin":false},"assignees":[{"login":"christopheranderson","id":2252976,"avatar_url":"https://avatars.githubusercontent.com/u/2252976?v=3","gravatar_id":"","url":"https://api.github.com/users/christopheranderson","html_url":"https://github.com/christopheranderson","followers_url":"https://api.github.com/users/christopheranderson/followers","following_url":"https://api.github.com/users/christopheranderson/following{/other_user}","gists_url":"https://api.github.com/users/christopheranderson/gists{/gist_id}","starred_url":"https://api.github.com/users/christopheranderson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christopheranderson/subscriptions","organizations_url":"https://api.github.com/users/christopheranderson/orgs","repos_url":"https://api.github.com/users/christopheranderson/repos","events_url":"https://api.github.com/users/christopheranderson/events{/privacy}","received_events_url":"https://api.github.com/users/christopheranderson/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/milestones/4","html_url":"https://github.com/Azure/azure-webjobs-sdk-script/milestones/Next%20-%20Triaged","labels_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/milestones/4/labels","id":1682707,"number":4,"title":"Next - Triaged","description":"Work for the next iteration","creator":{"login":"christopheranderson","id":2252976,"avatar_url":"https://avatars.githubusercontent.com/u/2252976?v=3","gravatar_id":"","url":"https://api.github.com/users/christopheranderson","html_url":"https://github.com/christopheranderson","followers_url":"https://api.github.com/users/christopheranderson/followers","following_url":"https://api.github.com/users/christopheranderson/following{/other_user}","gists_url":"https://api.github.com/users/christopheranderson/gists{/gist_id}","starred_url":"https://api.github.com/users/christopheranderson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christopheranderson/subscriptions","organizations_url":"https://api.github.com/users/christopheranderson/orgs","repos_url":"https://api.github.com/users/christopheranderson/repos","events_url":"https://api.github.com/users/christopheranderson/events{/privacy}","received_events_url":"https://api.github.com/users/christopheranderson/received_events","type":"User","site_admin":false},"open_issues":42,"closed_issues":7,"state":"open","created_at":"2016-04-04T18:21:33Z","updated_at":"2016-08-16T00:00:33Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2016-08-12T14:31:10Z","updated_at":"2016-08-16T09:00:06Z","closed_at":null,"body":"Using :\r\n - Azure Function : ~0.4\r\n - Node.js : 5.9.1\r\n\r\nI've been using Azure Function with Node.js without any problem.\r\nThen I decided to transpil my code with Babel.js to make use of await/async.\r\nA strange bug appeared.. an Azure Function timeout.\r\nI tried many things and after only adding logging, the timeout disappeared... \r\n\r\nHere is the transpiled code with the console.log line.. If I remove this single line, my Azure Function will timeout.\r\n\r\n**Index.js**\r\n```js\r\n\"use strict\";\r\n\r\nmodule.exports = require(\"./lib/handle\");\r\n```\r\n\r\n**lib/handle.js**\r\n```js\r\n\"use strict\";\r\n\r\nObject.defineProperty(exports, \"__esModule\", {\r\n  value: true\r\n});\r\nexports.default = handle;\r\n\r\nvar _EndPoint = require(\"./EndPoint\");\r\n\r\nvar _EndPoint2 = _interopRequireDefault(_EndPoint);\r\n\r\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\r\n\r\n// endPoint may be reused for many requests\r\nconst endPoint = new _EndPoint2.default();\r\n\r\n/**\r\n * Basic Azure Function handle\r\n *\r\n * @param {Object} context Context object\r\n * @param {Object} req Request object\r\n */\r\nfunction handle() {\r\n\r\n  /* eslint no-console: 1 */\r\n  // TODO: Next line is a hack to avoid timeout on Azure\r\n  console.log(\"Starting...\");\r\n\r\n  endPoint.handle(...arguments);\r\n}\r\nmodule.exports = exports[\"default\"];\r\n```\r\n\r\nMicrosoft Support : I can give you my Azure Function URL in private"},"comment":{"url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/issues/comments/240044828","html_url":"https://github.com/Azure/azure-webjobs-sdk-script/issues/572#issuecomment-240044828","issue_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/issues/572","id":240044828,"user":{"login":"yvele","id":4225430,"avatar_url":"https://avatars.githubusercontent.com/u/4225430?v=3","gravatar_id":"","url":"https://api.github.com/users/yvele","html_url":"https://github.com/yvele","followers_url":"https://api.github.com/users/yvele/followers","following_url":"https://api.github.com/users/yvele/following{/other_user}","gists_url":"https://api.github.com/users/yvele/gists{/gist_id}","starred_url":"https://api.github.com/users/yvele/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yvele/subscriptions","organizations_url":"https://api.github.com/users/yvele/orgs","repos_url":"https://api.github.com/users/yvele/repos","events_url":"https://api.github.com/users/yvele/events{/privacy}","received_events_url":"https://api.github.com/users/yvele/received_events","type":"User","site_admin":false},"created_at":"2016-08-16T09:00:06Z","updated_at":"2016-08-16T09:00:06Z","body":"@christopheranderson Yes sure.. I already gave post transpiled code but here is everything :\r\n\r\n# Pre transpilled\r\n\r\n### Index.js\r\n\r\n```js\r\n\"use strict\";\r\n\r\nmodule.exports = require(\"./lib/handle\");\r\n\r\n```\r\n\r\n### src/handle.js\r\n\r\n```js\r\nimport EndPoint from \"./EndPoint\";\r\n\r\n// May be reused for many requests\r\nconst endPoint = new EndPoint();\r\n\r\n/**\r\n * Basic Azure Function handle\r\n *\r\n * @param {Object} context Context object\r\n * @param {Object} req Request object\r\n */\r\nexport default function handle(...args) {\r\n\r\n  /* eslint no-console: 1 */\r\n  // TODO: Next line is a hack to avoid timeout on Azure\r\n  console.log(\"Starting...\");\r\n\r\n  endPoint.handleRaw(...args);\r\n}\r\n```\r\n\r\n### src/EndPoint.js\r\n\r\n```js\r\nimport BaseEndPoint from \"@my-orga/helpers/lib/BaseEndPoint\";\r\n\r\nexport default class EndPoint extends BaseEndPoint {\r\n  async handleCore(req, res) {\r\n    res.status = 200;\r\n    res.body = {\r\n      action  : \"Herr Vector\",\r\n      headers : req.headers\r\n    };\r\n  }\r\n}\r\n```\r\n\r\n### @my-orga/helpers/BaseEndPoint.js\r\n\r\n```js\r\nexport default class BaseEndPoint {\r\n\r\n  /**\r\n   * Basic Azure Function handle\r\n   *\r\n   * @param {Object} context Context object\r\n   * @param {Object} req Request object\r\n   */\r\n  handleRaw(context, req) {\r\n    context.res = {};\r\n\r\n    const promise = this.handle(req, context.res);\r\n    if (!promise || !promise.then) {\r\n      // Didn't returned a promise\r\n      context.done();\r\n      return;\r\n    }\r\n\r\n    promise.then(context::context.done, error => {\r\n\r\n      // TODO: Proper error handling\r\n      /* eslint no-console: 1 */\r\n      console.error(error);\r\n\r\n      // TODO: If security error then send a 404 instead\r\n      context.done(error);\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Handles the request\r\n   *\r\n   * @param {Object} req Request\r\n   * @param {Object} res Response\r\n   */\r\n  async handle(req, res) {\r\n    await this.handleCore(req, res);\r\n  }\r\n\r\n  /**\r\n   * Handles the request at a domain level\r\n   *\r\n   * @param {Object} req Request\r\n   * @param {Object} res Response\r\n   */\r\n  async handleCore(/* req, res */) {\r\n    throw new Error(\"Method not implemented\");\r\n  }\r\n\r\n}\r\n```\r\n\r\n# Post transpilled\r\n\r\n```js\r\n\"use strict\";\r\n\r\nmodule.exports = require(\"./lib/handle\");\r\n\r\n```\r\n\r\n### src/handle.js\r\n\r\n```js\r\n\"use strict\";\r\n\r\nObject.defineProperty(exports, \"__esModule\", {\r\n  value: true\r\n});\r\nexports.default = handle;\r\n\r\nvar _EndPoint = require(\"./EndPoint\");\r\n\r\nvar _EndPoint2 = _interopRequireDefault(_EndPoint);\r\n\r\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\r\n\r\n// May be reused for many requests\r\nconst endPoint = new _EndPoint2.default();\r\n\r\n/**\r\n * Basic Azure Function handle\r\n *\r\n * @param {Object} context Context object\r\n * @param {Object} req Request object\r\n */\r\nfunction handle() {\r\n\r\n  /* eslint no-console: 1 */\r\n  // TODO: Next line is a hack to avoid timeout on Azure\r\n  console.log(\"Starting...\");\r\n\r\n  endPoint.handleRaw(...arguments);\r\n}\r\nmodule.exports = exports[\"default\"];\r\n```\r\n\r\n### EndPoint.js\r\n\r\n```js\r\n\"use strict\";\r\n\r\nObject.defineProperty(exports, \"__esModule\", {\r\n  value: true\r\n});\r\n\r\nvar _BaseEndPoint = require(\"@my-orga/helpers/lib/BaseEndPoint\");\r\n\r\nvar _BaseEndPoint2 = _interopRequireDefault(_BaseEndPoint);\r\n\r\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\r\n\r\nfunction _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { return step(\"next\", value); }, function (err) { return step(\"throw\", err); }); } } return step(\"next\"); }); }; } /* eslint import/no-unresolved: 1 */\r\n\r\n\r\nclass EndPoint extends _BaseEndPoint2.default {\r\n\r\n  handleCore(req, res) {\r\n    return _asyncToGenerator(function* () {\r\n      res.status = 200;\r\n      res.body = {\r\n        action: \"Herr Vector\",\r\n        headers: req.headers\r\n      };\r\n    })();\r\n  }\r\n\r\n}\r\nexports.default = EndPoint;\r\nmodule.exports = exports[\"default\"];\r\n```\r\n\r\n\r\n### @my-orga/helpers/BaseEndPoint.js\r\n\r\n```js\r\n\"use strict\";\r\n\r\nObject.defineProperty(exports, \"__esModule\", {\r\n  value: true\r\n});\r\n\r\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\r\n\r\nfunction _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { return step(\"next\", value); }, function (err) { return step(\"throw\", err); }); } } return step(\"next\"); }); }; }\r\n\r\nclass BaseEndPoint {\r\n\r\n  /**\r\n   * Basic Azure Function handle\r\n   *\r\n   * @param {Object} context Context object\r\n   * @param {Object} req Request object\r\n   */\r\n  handleRaw(context, req) {\r\n    context.res = {};\r\n\r\n    const promise = this.handle(req, context.res);\r\n    if (!promise || !promise.then) {\r\n      // Didn't returned a promise\r\n      context.done();\r\n      return;\r\n    }\r\n\r\n    promise.then(context.done.bind(context), error => {\r\n\r\n      // TODO: Proper error handling\r\n      /* eslint no-console: 1 */\r\n      console.error(error);\r\n\r\n      // TODO: If security error then send a 404 instead\r\n      context.done(error);\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Handles the request\r\n   *\r\n   * @param {Object} req Request\r\n   * @param {Object} res Response\r\n   */\r\n  handle(req, res) {\r\n    var _this = this;\r\n\r\n    return _asyncToGenerator(function* () {\r\n        yield _this.handleCore(req, res);\r\n    })();\r\n  }\r\n\r\n  /**\r\n   * Handles the request at a domain level\r\n   *\r\n   * @param {Object} req Request\r\n   * @param {Object} res Response\r\n   */\r\n  handleCore() /* req, res */{\r\n    return _asyncToGenerator(function* () {\r\n      throw new Error(\"Method not implemented\");\r\n    })();\r\n  }\r\n\r\n}\r\nexports.default = BaseEndPoint;\r\nmodule.exports = exports[\"default\"];\r\n```\r\n\r\nAll dependencies are copied into node_modules\r\nI'm transpilling with babel.js :\r\n\r\n### .babelrc\r\n\r\n```json\r\n{\r\n  \"presets\": [\"es2015-node5\", \"stage-0\"],\r\n  \"plugins\": [\r\n    \"add-module-exports\"\r\n  ]\r\n}\r\n```\r\n"}}
{"actor":{"display_login":"yvele"}}