Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fixing zone from which to fork a new zone #1209

Merged
merged 3 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class ZoneContextManager implements ContextManager {
* @param context A context (span) to be bind with Zone
*/
private _createZone(zoneName: string, context: unknown): Zone {
return Zone.root.fork({
return Zone.current.fork({
name: zoneName,
properties: {
[ZONE_CONTEXT_KEY]: context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,23 @@ describe('ZoneContextManager', () => {
});
});
});

it('should fork new zone from active one', () => {
const context = Context.ROOT_CONTEXT;
const rootZone = Zone.current;
contextManager.with(context, () => {
const zone1 = Zone.current;
assert.ok(zone1.parent === rootZone);
contextManager.with(context, () => {
const zone2 = Zone.current;
contextManager.with(context, () => {
const zone3 = Zone.current;
assert.ok(zone3.parent === zone2);
});
assert.ok(zone2.parent === zone1);
});
});
});
});

describe('.bind(function)', () => {
Expand Down