From f63dafc62473334a3080456ddeb297304275f2cf Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Wed, 12 May 2021 09:46:39 -0400 Subject: [PATCH] chore: document the reason for symbol.for --- src/context/context.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/context/context.ts b/src/context/context.ts index 0be6163e..f6a87ba4 100644 --- a/src/context/context.ts +++ b/src/context/context.ts @@ -126,6 +126,12 @@ export function setBaggage(context: Context, baggage: Baggage): Context { /** Get a key to uniquely identify a context value */ export function createContextKey(description: string) { + // The specification states that for the same input, multiple calls should + // return different keys. Due to the nature of the JS dependency management + // system, this creates problems where multiple versions of some package + // could hold different keys for the same property. + // + // Therefore, we use Symbol.for which returns the same key for the same input. return Symbol.for(description); }