Skip to content

Promises wiggle their way between nextTick and setImmediate #2736

@ghost

Description

This doesn't seem right to me, but feel free to close if it is. Promises somehow always get in between nextTick and setImmediate. This was causing a weird timing bug for me when I switched some code from Bluebird to native promises:

~function(){ setTimeout (console.log.bind(console, 'timeout A')); process.nextTick (console.log.bind(console, 'nextTick A')); setImmediate (console.log.bind(console, 'setImmediate A')); Promise.resolve().then(console.log.bind(console, 'promise')); process.nextTick (console.log.bind(console, 'nextTick B')); setImmediate (console.log.bind(console, 'setImmediate B')); setTimeout (console.log.bind(console, 'timeout B')); }();

Native yields:

nextTick A nextTick B promise undefined setImmediate A setImmediate B timeout A timeout B 

Bluebird yields:

nextTick A nextTick B setImmediate A promise undefined setImmediate B timeout A timeout B 

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionIssues that look for answers.v8 engineIssues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions