Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Wrong current zone observed inside Bluebird's then() #921

@vkopyl

Description

@vkopyl

Hi!

Observing the issue when using bluebird module. Fork a zone 'A' with a bluebird promise in run. Check Zone.current.name in then function. In should be 'A'. Fork a new zone, 'B', check Zone.current in then. Expected 'B', but it still reports 'A'.

(running in Node v6.11.3)

Please check: https://runkit.com/vkopyl/test-bluebird-with-zone-js

require('zone.js/dist/zone-node.js');
const Bluebird = require('bluebird');
require('zone.js/dist/zone-bluebird.min');
Zone[Zone['__symbol__']('bluebird')](Bluebird);

Zone.current.fork({
  name: 'zone_A'
}).run(() => {
  new Bluebird((resolve, reject) => {
    console.log('in promise A: ' + Zone.current.name);
    resolve(1);
  }).then(r => {
    console.log('inside then A: ' + Zone.current.name);
  });
});

Zone.current.fork({
  name: 'zone_B'
}).run(() => {
  new Bluebird((resolve, reject) => {
    console.log('in promise B: ' + Zone.current.name);
    resolve(2);
  }).then(r => {
    console.log('inside then B: ' + Zone.current.name); // expected zone_B, reports zone_A
  });
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions