{"action":"created","issue":{"url":"https://api.github.com/repos/petkaantonov/bluebird/issues/1059","repository_url":"https://api.github.com/repos/petkaantonov/bluebird","labels_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/1059/labels{/name}","comments_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/1059/comments","events_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/1059/events","html_url":"https://github.com/petkaantonov/bluebird/issues/1059","id":144361071,"number":1059,"title":"Feature Request: Alternate way to suppress warnings","user":{"login":"ben-page","id":744035,"avatar_url":"https://avatars.githubusercontent.com/u/744035?v=3","gravatar_id":"","url":"https://api.github.com/users/ben-page","html_url":"https://github.com/ben-page","followers_url":"https://api.github.com/users/ben-page/followers","following_url":"https://api.github.com/users/ben-page/following{/other_user}","gists_url":"https://api.github.com/users/ben-page/gists{/gist_id}","starred_url":"https://api.github.com/users/ben-page/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ben-page/subscriptions","organizations_url":"https://api.github.com/users/ben-page/orgs","repos_url":"https://api.github.com/users/ben-page/repos","events_url":"https://api.github.com/users/ben-page/events{/privacy}","received_events_url":"https://api.github.com/users/ben-page/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2016-03-29T19:17:12Z","updated_at":"2016-08-19T18:36:32Z","closed_at":null,"body":"1) What version of bluebird is the issue happening on? **3.3.4**\r\n2) What platform and version? **Node v5.9.1**\r\n3) Did this issue happen with earlier version of bluebird? **Yes**\r\n\r\nLibrary authors can't suppress the warning for runaway promises that they create, because it's not the runaway Promise that needs to resolve to null, but the outer promise. Consider the following example:\r\n\r\n```javascript\r\n'use strict';\r\nvar Promise = require('bluebird');\r\nPromise.config({warnings: true, longStackTraces: true});\r\n\r\nfunction otherLibrary() {\r\n    Promise.resolve()\r\n        .catch(function() {\r\n            //totally recover from error\r\n        })\r\n        .then(function () {\r\n            return null; //try to tell Bluebird we don't need the warning\r\n        });\r\n}\r\n\r\nPromise.resolve()\r\n    .then(function () {\r\n        otherLibrary();\r\n    })\r\n    .delay(500); //on Windows node doesn't flush the console stream before exiting\r\n```\r\n\r\nThis triggers a runaway promise warning even though, `otherLibrary` is trying to indicate that it wants to suppress the warning. So consumers of the library have to be aware of this and suppress the warning at every call, if they use promises as well.\r\n\r\n```javascript\r\nPromise.resolve()\r\n    .then(function () {\r\n        otherLibrary();\r\n        return null; //this will suppress the warning\r\n    })\r\n    .delay(500); //on Windows node doesn't flush the console stream before exiting\r\n```\r\n\r\nI realize that the warning is thrown when the runaway promise is created, not when it's resolved. So the `otherLibrary` returning null is irrelevant. But, it would be nice to have a way to suppress the warning when creating the runaway promise.\r\n\r\nMaybe a simple call that suppresses the warning for the next promise created.\r\n```javascript\r\nfunction otherLibrary() {\r\n    Promise.suppressRunawayWarning();\r\n    Promise.resolve()\r\n        .catch(function() {\r\n            //totally recover from error\r\n        });\r\n}\r\n```\r\n\r\nOr maybe it would be better to explicitly start a new promise chain.\r\n```javascript\r\nfunction otherLibrary() {\r\n    Promise\r\n        .newChain()\r\n        .resolve()\r\n        .catch(function () {\r\n            //totally recover from error\r\n        });\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/petkaantonov/bluebird/issues/comments/241099621","html_url":"https://github.com/petkaantonov/bluebird/issues/1059#issuecomment-241099621","issue_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/1059","id":241099621,"user":{"login":"ErisDS","id":101513,"avatar_url":"https://avatars.githubusercontent.com/u/101513?v=3","gravatar_id":"","url":"https://api.github.com/users/ErisDS","html_url":"https://github.com/ErisDS","followers_url":"https://api.github.com/users/ErisDS/followers","following_url":"https://api.github.com/users/ErisDS/following{/other_user}","gists_url":"https://api.github.com/users/ErisDS/gists{/gist_id}","starred_url":"https://api.github.com/users/ErisDS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ErisDS/subscriptions","organizations_url":"https://api.github.com/users/ErisDS/orgs","repos_url":"https://api.github.com/users/ErisDS/repos","events_url":"https://api.github.com/users/ErisDS/events{/privacy}","received_events_url":"https://api.github.com/users/ErisDS/received_events","type":"User","site_admin":false},"created_at":"2016-08-19T18:36:32Z","updated_at":"2016-08-19T18:36:32Z","body":"I'd also like to ask about an additional way to suppress or configure the warnings thrown from Bluebird, but with regard to the [a promise was rejected with a non-error](https://github.com/petkaantonov/bluebird/blob/master/docs/docs/warning-explanations.md#warning-a-promise-was-rejected-with-a-non-error) warning.\r\n\r\nI agree with, and appreciate the opinions that bluebird enforces about not rejecting promises with primitive values. However, in Ghost (and other similar API-providing software) we sometimes want to reject promises with an Array of Errors, rather than a single Error. This is specifically useful when doing validations where we want to validate multiple fields at once.\r\n\r\nIn this case, we are not breaking the rule of rejecting with an error, there just happens to be more than one 😉 .\r\n\r\nI understand that this may be an edge case that doesn't fit into the \"work for 90% of cases 100% of the time\" rule. I just wanted to flag up this use case as one of perhaps a set of cases where you might want to be able to suppress the warnings only sometimes, and put in a request for this feature.\r\n\r\nWe're currently getting lots of warnings, but I'd love to have some mechanism whereby we could only get them when we're not returning an array but for example inadvertently returning something like `undefined` as that is super useful. \r\n\r\nThanks for listening, we ❤️  Bluebird."}}
{"actor":{"display_login":"ErisDS"}}