Skip to content

Commit 19856c6

Browse files
committed
feat(context): make parent public for invocation context
Some interceptors such as tracing need to add bindings to the parent, which is typically the request context.
1 parent e211a71 commit 19856c6

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

packages/context/src/__tests__/unit/invocation-context.unit.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ describe('InvocationContext', () => {
4343
);
4444
});
4545

46+
it('has public access to parent context', () => {
47+
expect(invocationCtxForGreet.parent).to.equal(ctx);
48+
});
49+
4650
it('throws error if method does not exist', () => {
4751
expect(() => invalidInvocationCtx.assertMethodExists()).to.throw(
4852
'Method MyController.prototype.invalid-method not found',

packages/context/src/interceptor.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ export class InvocationContext extends Context {
6060
* @param args - An array of arguments
6161
*/
6262
constructor(
63-
parent: Context,
63+
// Make `parent` public so that the interceptor can add bindings to
64+
// the request context, for example, tracing id
65+
public readonly parent: Context,
6466
public readonly target: object,
6567
public readonly methodName: string,
6668
public readonly args: InvocationArgs,

0 commit comments

Comments
 (0)