{"action":"opened","issue":{"url":"https://api.github.com/repos/promises-aplus/promises-spec/issues/217","labels_url":"https://api.github.com/repos/promises-aplus/promises-spec/issues/217/labels{/name}","comments_url":"https://api.github.com/repos/promises-aplus/promises-spec/issues/217/comments","events_url":"https://api.github.com/repos/promises-aplus/promises-spec/issues/217/events","html_url":"https://github.com/promises-aplus/promises-spec/issues/217","id":116089684,"number":217,"title":"Can you assist me in satisfying promises aplus spec 2.2.4 in NodeJS?","user":{"login":"danday74","id":9257644,"avatar_url":"https://avatars.githubusercontent.com/u/9257644?v=3","gravatar_id":"","url":"https://api.github.com/users/danday74","html_url":"https://github.com/danday74","followers_url":"https://api.github.com/users/danday74/followers","following_url":"https://api.github.com/users/danday74/following{/other_user}","gists_url":"https://api.github.com/users/danday74/gists{/gist_id}","starred_url":"https://api.github.com/users/danday74/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danday74/subscriptions","organizations_url":"https://api.github.com/users/danday74/orgs","repos_url":"https://api.github.com/users/danday74/repos","events_url":"https://api.github.com/users/danday74/events{/privacy}","received_events_url":"https://api.github.com/users/danday74/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-10T11:38:23Z","updated_at":"2015-11-10T11:38:23Z","closed_at":null,"body":"I am writing an HTTP Promises package for nodeJS. I need it to be promises aplus compliant. I am using promises-aplus-tests - https://www.npmjs.com/package/promises-aplus-tests\r\n\r\nI have created an adapter as follows ..\r\n\r\n``` javascript\r\nvar adapter = {\r\n    deferred: function() {\r\n        var d = {}\r\n        d.promise = new HTTPromise(new GETOptions('/path', DEFAULT_OPTIONS));\r\n        d.resolve = executorResponseFunc;\r\n        d.reject = executorRejectFunc;        \r\n        return d;\r\n    }\r\n}\r\n\r\npromisesAplusTests(adapter, function (err) {\r\n    done(err);\r\n});\r\n```\r\n\r\nMy tests are failin on https://promisesaplus.com/#point-34 ... with further help on https://promisesaplus.com/#point-67\r\n\r\n    2.2.4 onFulfilled or onRejected must not be called until the execution context stack contains only platform code\r\n\r\n    3.1 Here “platform code” means engine, environment, and promise implementation code. In practice, this requirement ensures that onFulfilled and onRejected execute asynchronously, after the event loop turn in which then is called, and with a fresh stack. This can be implemented with either a “macro-task” mechanism such as setTimeout or setImmediate, or with a “micro-task” mechanism such as MutationObserver or process.nextTick. Since the promise implementation is considered platform code, it may itself contain a task-scheduling queue or “trampoline” in which the handlers are called.\r\n\r\nBut I can't get it passing this promises aplus test. I am using the bog standard JavaScript Promises library (which on its own passes the tests) documented at ...\r\n\r\nhttps://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise\r\n\r\nnew Promise(executor);\r\n\r\nnew Promise(function(resolve, reject) { ... });\r\n\r\nIn the executor I have tried ...\r\n\r\nif (response.statusCode === 200) {\r\n    process.nextTick(() => {\r\n        resolve(finalResponse);   \r\n    });\r\n} else {\r\n    process.nextTick(() => {\r\n        reject(finalResponse);\r\n    });\r\n}\r\n\r\nand also ...\r\n\r\nprocess.nextTick(() => {\r\n    if (response.statusCode === 200) {\r\n        resolve(finalResponse);      \r\n    } else {\r\n         reject(finalResponse);\r\n    }\r\n});\r\n\r\nThere seems to be a lot of talk on the Internet but not many code examples of how to comply. Can anyone provide a code sample please on how to satisfy this test and how you would use nextTick or another suitable solution?\r\n\r\nMany thanks\r\n"}}