( providerLabel: string, context: CallApiContextParams | undefined, )
| 31 | * @returns A sanitized clone, or `undefined` if `context` was `undefined`. |
| 32 | */ |
| 33 | export function sanitizeScriptContext( |
| 34 | providerLabel: string, |
| 35 | context: CallApiContextParams | undefined, |
| 36 | ): CallApiContextParams | undefined { |
| 37 | if (!context) { |
| 38 | return undefined; |
| 39 | } |
| 40 | |
| 41 | const sanitizedContext = { ...context }; |
| 42 | const stripped: string[] = []; |
| 43 | for (const key of NON_SERIALIZABLE_CONTEXT_KEYS) { |
| 44 | if (key in sanitizedContext) { |
| 45 | stripped.push(key); |
| 46 | delete sanitizedContext[key]; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | if (stripped.length > 0) { |
| 51 | logger.debug( |
| 52 | `${providerLabel} sanitized context: stripped non-serializable keys [${stripped.join(', ')}]`, |
| 53 | ); |
| 54 | } |
| 55 | |
| 56 | return sanitizedContext; |
| 57 | } |
no test coverage detected
searching dependent graphs…