As of Node.js 8.0.0, the handlers of promises are run inside the domain in which the call to .then() or .catch() itself was made:

    1. const d1 = domain.create();
    2. const d2 = domain.create();
    3. let p;
    4. d1.run(() => {
    5. p = Promise.resolve(42);
    6. });
    7. d2.run(() => {
    8. p.then((v) => {
    9. // running in d2
    10. });
    11. });

    A callback may be bound to a specific domain using [domain.bind(callback)][]:

    1. const d1 = domain.create();
    2. const d2 = domain.create();
    3. let p;
    4. d1.run(() => {
    5. p = Promise.resolve(42);
    6. });
    7. d2.run(() => {
    8. p.then(p.domain.bind((v) => {
    9. // running in d1
    10. }));
    11. });

    Domains will not interfere with the error handling mechanisms for promises. In other words, no 'error' event will be emitted for unhandled Promise rejections.