-
Notifications
You must be signed in to change notification settings - Fork 418
fix(nextjs): Keyless drift detection telemetry bug from usage of async methods #6594
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@clerk/nextjs": patch | ||
| --- | ||
|
|
||
| Fix keyless drift detection failing constantly due to usage of invalid methods from the fs module | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,18 +44,18 @@ function getTelemetryFlagFilePath(): string { | |
| async function tryMarkTelemetryEventAsFired(): Promise<boolean> { | ||
| try { | ||
| if (canUseKeyless) { | ||
| const { mkdir, writeFile } = nodeFsOrThrow(); | ||
| const { mkdirSync, writeFileSync } = nodeFsOrThrow(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify nodeFsOrThrow exposes sync variants in all runtimes. We now rely on Run this repo-scoped script to confirm the implementation and typings of 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "Locate nodeFsOrThrow definition and ensure it returns mkdirSync/writeFileSync:"
rg -nP -C3 'export\s+(function|const)\s+nodeFsOrThrow\b|nodeFsOrThrow\s*\(' --type ts
echo
echo "Check for sync fs members in the returned object:"
rg -nP -C2 'mkdirSync|writeFileSync' --type ts | sed -n '1,200p'Length of output: 10556 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "Locate utils.ts in packages/nextjs/src/server/fs:"
fd --base-directory packages/nextjs/src/server/fs -t f utils.ts
echo
echo "Display first 200 lines of utils.ts to inspect nodeFsOrThrow definition and its typing:"
sed -n '1,200p' packages/nextjs/src/server/fs/utils.tsLength of output: 1302 Enforce FS sync methods in types At runtime To fully verify and enforce that callers always have access to the sync variants, please:
These changes ensure the compiler will flag any missing sync methods immediately and align the types with the actual runtime behavior. 🤖 Prompt for AI Agents |
||
| const flagFilePath = getTelemetryFlagFilePath(); | ||
| const flagDirectory = dirname(flagFilePath); | ||
|
|
||
| // Ensure the directory exists before attempting to write the file | ||
| await mkdir(flagDirectory, { recursive: true }); | ||
| await mkdirSync(flagDirectory, { recursive: true }); | ||
|
|
||
| const flagData = { | ||
| firedAt: new Date().toISOString(), | ||
| event: EVENT_KEYLESS_ENV_DRIFT_DETECTED, | ||
| }; | ||
| await writeFile(flagFilePath, JSON.stringify(flagData, null, 2), { flag: 'wx' }); | ||
| await writeFileSync(flagFilePath, JSON.stringify(flagData, null, 2), { flag: 'wx' }); | ||
| return true; | ||
| } else { | ||
| return false; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.