-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include clerkTraceId for backend api errors #1894
Conversation
🦋 Changeset detectedLatest commit: 1c04f6c The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
c1305f8
to
5f4fade
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @Nikpolik 👏 !
c5d6fc0
to
83f200a
Compare
83f200a
to
99d6b0e
Compare
7dfdf84
to
16b44aa
Compare
clerkTraceId is used when available and defaults to cloudflares CF Ray id when its missing.
16b44aa
to
1c04f6c
Compare
@Nikpolik Could you also cherry-pick this change into |
…1894) clerkTraceId is used when available and defaults to cloudflares CF Ray id when its missing.
Description
This PR adds
clerkTraceId
inClerkBackendApiResponse
. This can help debug issues with API responses especially when errors happen server side or transiently and they can't be viewed in the console.Changes
ClerkAPIResponseError
from@clerk/shared
.ClerkBackendApiResponse
interface to includeclerkTraceId
when available.clerkTraceId
either from backend error response or headers inbuildRequest
.clerkTraceId
value towithLegacyReturn
and then to the constructor ofClerkAPIResponseError
.toString
forClerkAPIResponseError
so it can also log the clerkTraceId.Now callining
.toString()
on an error should show the trace idThe same is true for simply calling console.log on the error
Notes
DX is a bit weird here since fields that are different between success and error cannot be accessed by default in typescript and they do not appear in code completion(intelisense/language server). They can be accessed however by
checking if they exist in the object.
Checklist
npm test
runs as expected.npm run build
runs as expected.Type of change
Packages affected
@clerk/clerk-js
@clerk/clerk-react
@clerk/nextjs
@clerk/remix
@clerk/types
@clerk/themes
@clerk/localizations
@clerk/clerk-expo
@clerk/backend
@clerk/clerk-sdk-node
@clerk/shared
@clerk/fastify
@clerk/chrome-extension
gatsby-plugin-clerk
build/tooling/chore