diff --git a/packages/context/src/__tests__/unit/invocation-context.unit.ts b/packages/context/src/__tests__/unit/invocation-context.unit.ts index 77a0ab5a6d33..860594c1d591 100644 --- a/packages/context/src/__tests__/unit/invocation-context.unit.ts +++ b/packages/context/src/__tests__/unit/invocation-context.unit.ts @@ -43,6 +43,10 @@ describe('InvocationContext', () => { ); }); + it('has public access to parent context', () => { + expect(invocationCtxForGreet.parent).to.equal(ctx); + }); + it('throws error if method does not exist', () => { expect(() => invalidInvocationCtx.assertMethodExists()).to.throw( 'Method MyController.prototype.invalid-method not found', diff --git a/packages/context/src/interceptor.ts b/packages/context/src/interceptor.ts index 0430b3531786..2fcacc81328c 100644 --- a/packages/context/src/interceptor.ts +++ b/packages/context/src/interceptor.ts @@ -60,7 +60,9 @@ export class InvocationContext extends Context { * @param args - An array of arguments */ constructor( - parent: Context, + // Make `parent` public so that the interceptor can add bindings to + // the request context, for example, tracing id + public readonly parent: Context, public readonly target: object, public readonly methodName: string, public readonly args: InvocationArgs,