Conversation
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
View your CI Pipeline Execution ↗ for commit ee84b94
☁️ Nx Cloud last updated this comment at |
| const checkRemote = process.env.NX_SKIP_CHECK_REMOTE !== 'true'; | ||
| await ( | ||
| await handleImport('./connect-to-nx-cloud.js', __dirname) | ||
| ).connectToNxCloudCommand({ ...args, checkRemote }); |
There was a problem hiding this comment.
Can you move this logic into connectToNxCloudCommand itself and keep this file as is?
| @@ -3,6 +3,15 @@ import { handleImport } from '../../../utils/handle-import'; | |||
| import { linkToNxDevAndExamples } from '../../yargs-utils/documentation'; | |||
| import { nxVersion } from '../../../utils/versions'; | |||
| import { withVerbose } from '../../yargs-utils/shared-options'; | |||
| import { recordStat } from '../../../utils/ab-testing'; | |||
There was a problem hiding this comment.
we don't want to add these imports here because then it'll slow down every comand even if it's not connect
`nx init` error telemetry is largely opaque: ~22% of starts land in a bare `Command failed: npm install` bucket, and ~5% record an empty `errorMessage`. We can't tell what's actually going wrong. `nx connect` has no start/error events at all — failures (missing remote, auth, network) go untracked. Telemetry-only change. Child-process calls in init pipe stderr so the captured output reaches the error payload; error events now include `errorName` (from Node `e.code` or an extracted `E…`/`ERR_…` token like `E404`, `ERESOLVE`, `EINTEGRITY`, `ERR_PNPM_*`) and the same env context (`nodeVersion`, `os`, `packageManager`, `isCI`, `aiAgent`) as start events. `toErrorString` fixes the empty-message bucket. `nx connect` gains proper start/complete/error events. No behavioral fixes — once the enriched data comes in we'll prioritize real fixes by actual failure distribution. Fixes NXC-4262
There was a problem hiding this comment.
✅ The fix from Nx Cloud was applied automatically
We ran pnpm nx format to fix the format:check failure caused by unformatted code introduced in the telemetry changes. The two affected files — command-object.ts and utils.spec.ts — were not passed through Prettier before committing, which caused the CI format check to fail. These formatting-only changes will resolve the error without altering any logic.
Tip
✅ We verified this fix by re-running nx-cloud record -- nx format:check.
Suggested Fix changes
diff --git a/packages/nx/src/command-line/init/command-object.ts b/packages/nx/src/command-line/init/command-object.ts
index d653bfdb..a5a015e4 100644
--- a/packages/nx/src/command-line/init/command-object.ts
+++ b/packages/nx/src/command-line/init/command-object.ts
@@ -92,7 +92,9 @@ export const yargsInitCommand: CommandModule = {
// `stdio: 'pipe'`) so telemetry gets the real cause.
const stderr = readErrorStderr(error).trim();
const telemetryMessage = (
- stderr ? `${errorMessage} | stderr: ${stderr.slice(-250)}` : errorMessage
+ stderr
+ ? `${errorMessage} | stderr: ${stderr.slice(-250)}`
+ : errorMessage
).slice(0, 500);
// Structured code for bucketing. Prefer Node's `e.code` (set on
// syscall failures); fall back to E-codes/ERR_* extracted from full
diff --git a/packages/nx/src/command-line/init/implementation/utils.spec.ts b/packages/nx/src/command-line/init/implementation/utils.spec.ts
index 4dc71987..63e57435 100644
--- a/packages/nx/src/command-line/init/implementation/utils.spec.ts
+++ b/packages/nx/src/command-line/init/implementation/utils.spec.ts
@@ -328,7 +328,9 @@ describe('utils', () => {
describe('extractErrorName', () => {
it('prefers Node e.code when set', () => {
- expect(extractErrorName({ code: 'EACCES' }, 'stderr E404')).toBe('EACCES');
+ expect(extractErrorName({ code: 'EACCES' }, 'stderr E404')).toBe(
+ 'EACCES'
+ );
});
it.each([
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
View interactive diff ↗🎓 Learn more about Self-Healing CI on nx.dev
Co-authored-by: jaysoo <jaysoo@users.noreply.github.com>
Addresses PR review: command-object.ts should not pull in ab-testing, native (isAiAgent), utils helpers etc. at module load time — those run for every nx command. Move the start/error telemetry and AI-mode error output into the init-v2 outer handler, guarded by the `!inner` flag so the downloaded-latest nx re-invocation does not double-record. command-object.ts is now minimal again (yargs wiring only). v1 path left untouched; slated for deletion in a follow-up.
Remove 5 PR-added comments that restated the code they sat above: - configure-plugins.ts "Invoke the nx wrapper..." (try/catch makes it obvious) - utils.ts "stderr piped so the error carries it..." - utils.ts readErrorStderr JSDoc (self-describing) - utils.ts extractErrorName JSDoc (self-describing) - init-v2.ts "Structured code for bucketing..." (restates extractErrorName) Kept the genuine "why" comments (selfRecord rationale, PII-stack drop, toErrorString edge-case JSDoc, cursor-restore AI-agent caveat).
Current Behavior
nx initerror telemetry is largely opaque: ~22% of starts land in a bareCommand failed: npm installbucket, and ~5% record an emptyerrorMessage. We can't tell what's actually going wrong.nx connecthas no start/error events at all — failures (missing remote, auth, network) go untracked.Expected Behavior
Telemetry-only change. Child-process calls in init pipe stderr so the captured output reaches the error payload; error events now include
errorName(from Nodee.codeor an extractedE…/ERR_…token likeE404,ERESOLVE,EINTEGRITY,ERR_PNPM_*) and the same env context (nodeVersion,os,packageManager,isCI,aiAgent) as start events.toErrorStringfixes the empty-message bucket.nx connectgains proper start/complete/error events.No behavioral fixes — once the enriched data comes in we'll prioritize real fixes by actual failure distribution.
Related Issue(s)
Fixes NXC-4262