Conversation
| return new Promise((resolve) => | ||
| setTimeout(() => { | ||
| resolve(undefined); | ||
| resolveLogger!(); |
Check failure
Code scanning / CodeQL
Invocation of non-function Error
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 18 hours ago
In general, to fix an “invocation of non-function” issue, ensure that any value you call as a function is guaranteed to be a function at runtime, either by initializing it appropriately, guarding the call with a type check, or removing the call if it is unnecessary.
Here, resolveLogger is intended to be a function used to signal when the logger’s internal work has finished, but in this test we never assign it or await it. The test only cares that the auth flow does not wait for the slow logger; it never inspects or uses resolveLogger. Therefore the simplest, behavior-preserving fix is to stop calling resolveLogger entirely. The promise returned by slowLogger already resolves via resolve(undefined);, which is sufficient for the test’s purpose. Removing the resolveLogger!(); call ensures we no longer attempt to invoke a possibly-undefined value, while keeping the rest of the behavior (a slow, non-awaited logger) intact.
Concretely, in src/server/instrumentation.flow.test.ts, within the "EC-10: Slow async logger" describe block, update the setTimeout body so that it only calls resolve(undefined); and does not reference resolveLogger. You may optionally also remove the unused resolveLogger variable declaration, but given the instruction to minimize changes, we can leave the declaration in place even though it is unused; the key is to remove the unsafe invocation.
| @@ -603,7 +603,6 @@ | ||
| return new Promise((resolve) => | ||
| setTimeout(() => { | ||
| resolve(undefined); | ||
| resolveLogger!(); | ||
| }, 5000) | ||
| ) as any; | ||
| }; |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2527 +/- ##
==========================================
+ Coverage 90.15% 90.60% +0.45%
==========================================
Files 51 53 +2
Lines 6439 6708 +269
Branches 1292 1333 +41
==========================================
+ Hits 5805 6078 +273
+ Misses 623 619 -4
Partials 11 11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This change adds configurable instrumentation support to the SDK, enabling emitting events at various critical points of the SDK flows.
These events can be consumed using a callback.
Some use-cases for this feature:
Changes
Instrumentation infra:
These changes enable the actual instrumentation support.
instrumentation-emitter.ts:InstrumentationEmitterclass, helper methodsinstrumentation.flow.test.ts&instrumentation.test.ts: Teststypes/instrumentation.ts: Type definitionsEXAMPLES.md: DocumentationEvent call sites:
These changes add call sites to existing SDK code at important points. PII data is not sent to emitter from codebase itself, removing the need for a filteration step.
auth-client.ts: Most of the SDK flowsclient.ts: Configuration, one call siteUsage
1. Option1: Environment Variables
Option 2: Custom callback
Configure a callback in
Auth0ClientOptions:Tests
Added unit and flow tests for complete integration.