Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 0 additions & 83 deletions .claude/commands/ci-failures.md

This file was deleted.

120 changes: 120 additions & 0 deletions .claude/commands/pr-status.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# PR Status

Analyze PR status including CI failures and review comments.

## Usage

```
/pr-status [PR number]
```

- Without argument: Automatically detects PR from current branch
- With PR number: Analyzes the specified PR (e.g., `/pr-status 89049`)

## Instructions

1. Run the script to fetch PR status data:

```bash
node scripts/pr-status.js $ARGUMENTS
```

This fetches workflow runs, failed jobs, logs, and PR review comments, then generates markdown files.

2. Read the generated index file for a summary:

```bash
# Read scripts/pr-status/index.md
```

The index shows failed jobs, PR reviews, and inline review comments with links to details.

3. Spawn parallel haiku subagents to analyze the failing jobs (limit to 3-4 to avoid rate limits)
- **Agent prompt template** (copy-paste for each agent):

```
Analyze CI results for these jobs: scripts/pr-status/job-{id1}.md scripts/pr-status/job-{id2}.md
For each failing test, extract:
1. TEST FILE: (full path, e.g., test/production/required-server-files-ssr-404/test/index.test.ts)
2. TEST NAME: (the specific test case name)
3. JOB TYPE: (the kind of the job, e.g. turbopack production, webpack dev, rust check)
4. EXPECTED: (exact expected value from assertion)
5. RECEIVED: (exact received value from assertion)
6. CATEGORY: (assertion|timeout|routing|source-map|build|cli-output)
7. ROOT CAUSE: (one sentence hypothesis)
8. LOG FILE: (analysed log file that led to conclusion)
Return structured findings grouped by TEST FILE, not by job.

Also extract other failures that are not related to tests.
Identify if they are likely transient.

```

4. Spawn parallel haiku subagents to analyze review comments (if any review threads exist):
- **Agent prompt template**:

```
Analyze PR review comments from these files: scripts/pr-status/thread-{i}.md scripts/pr-status/review-{id}.md
For each review thread/comment, extract:
1. FILE: (the file path being reviewed)
2. REVIEWER: (who left the comment)
3. STATUS: (Open/Resolved for threads, APPROVED/CHANGES_REQUESTED/COMMENTED for reviews)
4. TYPE: (code-style|bug|design|question|suggestion|nitpick|blocker)
5. SUMMARY: (one sentence summary of the feedback)
6. ACTION REQUIRED: (yes/no - does this require changes?)
7. PRIORITY: (high if CHANGES_REQUESTED or blocker, medium if open suggestion, low if resolved or nitpick)
Return findings grouped by file path.
```

5. **Deduplicate by test file** before summarizing:
- Group all failures by TEST FILE path, not by CI job name
- If multiple jobs fail the same test file, count them but report once
- Identify systemic issues (same test failing across many jobs)

6. Analyze failures and review comments, create a summary:

**CI Failures (grouped by test file):**

| Test File | Type | Issue (Expected vs Received) | Jobs | Priority |
| --------------------------------------------------- | -------------- | ----------------------------------- | ---- | -------- |
| `test/production/required-server-files-ssr-404/...` | Turbopack prod | `"second"` vs `"[slug]"` (routing) | 3 | HIGH |
| `test/integration/server-side-dev-errors/...` | webpack dev | source map paths wrong | 5 | HIGH |
| `test/e2e/app-dir/disable-logging-route/...` | prod | "Compiling" appearing when disabled | 2 | MEDIUM |
| N/A | rust check | Formatting incorrect | 2 | MEDIUM |

**Review Feedback (grouped by file):**

| File | Reviewer | Type | Summary | Action Required | Priority |
| ---------------- | -------- | ---------- | -------------------------- | --------------- | -------- |
| `src/server/...` | reviewer | suggestion | Consider using async/await | yes | MEDIUM |
| `test/e2e/...` | reviewer | nitpick | Typo in comment | no | LOW |
| N/A | reviewer | blocker | Missing error handling | yes | HIGH |

7. Recommend fixes:
- **HIGH priority**: Show specific expected vs actual values, include test file path, address blocker review comments
- **MEDIUM priority**: Identify root cause pattern, address open suggestions
- **LOW priority**: Mark as likely flaky/transient, note resolved/nitpick comments

- Do not try to fix these failures or address review comments without user confirmation.
- If failures would require complex analysis and there are multiple problems, only do some basic analysis and point out that further investigation is needed and could be performed when requested.

## Failure Categories

- **Infrastructure/Transient**: Network errors, 503s, timeouts unrelated to code
- **Assertion Failures**: Wrong output, path mismatches, snapshot differences
- **Build Failures**: Compilation errors, missing dependencies
- **Timeout**: Tests hanging, usually indicates async issues or missing server responses
- **Port Binding**: EADDRINUSE errors, parallel test conflicts
- **Routing/SSR**: Dynamic params not resolved, wrong status codes, JSON parse errors
- **Source Maps**: `webpack-internal://` paths, wrong line numbers, missing code frames
- **CLI Output**: Missing warnings, wrong log order, "Ready" printed before errors

## Review Comment Categories

- **code-style**: Formatting, naming conventions, code organization
- **bug**: Potential bugs or logic errors
- **design**: Architectural or design concerns
- **question**: Questions about implementation or intent
- **suggestion**: Non-blocking improvements
- **nitpick**: Minor issues that don't require changes
- **blocker**: Must be addressed before merge
8 changes: 4 additions & 4 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ jobs:
secrets: inherit

test-new-tests-dev:
name: Test new tests for flakes (dev)
name: Test new and changed tests for flakes (dev)
needs: ['optimize-ci', 'changes', 'build-native', 'build-next']
# test-new-tests-if
if: ${{ needs.optimize-ci.outputs.skip == 'false' && needs.changes.outputs.docs-only == 'false' }}
Expand All @@ -650,7 +650,7 @@ jobs:
secrets: inherit

test-new-tests-start:
name: Test new tests for flakes (prod)
name: Test new and changed tests for flakes (prod)
needs: ['optimize-ci', 'changes', 'build-native', 'build-next']
# test-new-tests-if
if: ${{ needs.optimize-ci.outputs.skip == 'false' && needs.changes.outputs.docs-only == 'false' }}
Expand All @@ -674,7 +674,7 @@ jobs:
secrets: inherit

test-new-tests-deploy:
name: Test new tests when deployed
name: Test new and changed tests when deployed
needs:
['optimize-ci', 'test-prod', 'test-new-tests-dev', 'test-new-tests-start']
# test-new-tests-if
Expand All @@ -700,7 +700,7 @@ jobs:
secrets: inherit

test-new-tests-deploy-cache-components:
name: Test new tests when deployed (cache components)
name: Test new and changed tests when deployed (cache components)
needs:
[
'optimize-ci',
Expand Down
27 changes: 11 additions & 16 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,28 +181,23 @@ pnpm prettier-fix # Fix formatting only
pnpm types # TypeScript type checking
```

## Investigating CI Test Failures
## PR Status (CI Failures and Reviews)

**Use `/ci-failures` for automated analysis** - analyzes failing jobs in parallel and groups by test file.
When the user asks about CI failures, PR reviews, or the status of a PR, run the pr-status script:

**CI Analysis Tips:**
```bash
node scripts/pr-status.js # Auto-detects PR from current branch
node scripts/pr-status.js <number> # Analyze specific PR by number
```

- Don't spawn too many parallel agents hitting GitHub API (causes rate limits)
- Prioritize blocking jobs first: lint, types, then test jobs
- Use `gh api` for logs (works on in-progress runs), not `gh run view --log`
This fetches CI workflow runs, failed jobs, logs, and PR review comments, generating markdown files in `scripts/pr-status/`.

**Quick triage:**
**Use `/pr-status` for automated analysis** - analyzes failing jobs and review comments in parallel, groups failures by test file.

```bash
# List failed jobs for a PR
gh pr checks <pr-number> | grep fail

# Get failed job names
gh run view <run-id> --json jobs --jq '.jobs[] | select(.conclusion == "failure") | .name'
**CI Analysis Tips:**

# Search job logs for errors (completed runs only - use gh api for in-progress)
gh run view <run-id> --job <job-id> --log 2>&1 | grep -E "FAIL|Error|error:" | head -30
```
- Prioritize blocking jobs first: build, lint, types, then test jobs
- Prioritize CI failures over review comments

**Common failure patterns:**

Expand Down
6 changes: 4 additions & 2 deletions crates/next-core/src/next_client/transforms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use crate::{
next_config::NextConfig,
next_shared::transforms::{
debug_fn_name::get_debug_fn_name_rule, get_import_type_bytes_rule,
get_next_dynamic_transform_rule, get_next_font_transform_rule, get_next_image_rule,
get_next_lint_transform_rule, get_next_modularize_imports_rule,
get_import_type_json_rule, get_next_dynamic_transform_rule, get_next_font_transform_rule,
get_next_image_rule, get_next_lint_transform_rule, get_next_modularize_imports_rule,
get_next_pages_transforms_rule, get_server_actions_transform_rule,
next_cjs_optimizer::get_next_cjs_optimizer_rule,
next_disallow_re_export_all_in_page::get_next_disallow_export_all_in_page_rule,
Expand Down Expand Up @@ -117,5 +117,7 @@ pub async fn get_next_client_transforms_rules(
rules.push(get_import_type_bytes_rule());
}

rules.push(get_import_type_json_rule());

Ok(rules)
}
11 changes: 7 additions & 4 deletions crates/next-core/src/next_server/transforms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ use crate::{
next_config::NextConfig,
next_server::context::ServerContextType,
next_shared::transforms::{
get_import_type_bytes_rule, get_next_dynamic_transform_rule, get_next_font_transform_rule,
get_next_image_rule, get_next_lint_transform_rule, get_next_modularize_imports_rule,
get_next_pages_transforms_rule, get_next_track_dynamic_imports_transform_rule,
get_server_actions_transform_rule, next_cjs_optimizer::get_next_cjs_optimizer_rule,
get_import_type_bytes_rule, get_import_type_json_rule, get_next_dynamic_transform_rule,
get_next_font_transform_rule, get_next_image_rule, get_next_lint_transform_rule,
get_next_modularize_imports_rule, get_next_pages_transforms_rule,
get_next_track_dynamic_imports_transform_rule, get_server_actions_transform_rule,
next_cjs_optimizer::get_next_cjs_optimizer_rule,
next_disallow_re_export_all_in_page::get_next_disallow_export_all_in_page_rule,
next_edge_node_api_assert::next_edge_node_api_assert,
next_middleware_dynamic_assert::get_middleware_dynamic_assert_rule,
Expand Down Expand Up @@ -219,6 +220,8 @@ pub async fn get_next_server_transforms_rules(
rules.push(get_import_type_bytes_rule());
}

rules.push(get_import_type_json_rule());

Ok(rules)
}

Expand Down
13 changes: 11 additions & 2 deletions crates/next-core/src/next_shared/transforms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use turbo_tasks::ResolvedVc;
use turbo_tasks_fs::FileSystemPath;
use turbopack::module_options::{ModuleRule, ModuleRuleEffect, ModuleType, RuleCondition};
use turbopack_core::reference_type::{
EcmaScriptModulesReferenceSubType, ImportWithType, ReferenceType, UrlReferenceSubType,
EcmaScriptModulesReferenceSubType, ReferenceType, UrlReferenceSubType,
};
use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform};

Expand Down Expand Up @@ -129,12 +129,21 @@ pub(crate) fn get_import_type_bytes_rule() -> ModuleRule {
// Move this into turbopack once the feature is standardized
ModuleRule::new(
RuleCondition::ReferenceType(ReferenceType::EcmaScriptModules(
EcmaScriptModulesReferenceSubType::ImportWithType(ImportWithType::Bytes),
EcmaScriptModulesReferenceSubType::ImportWithType("bytes".into()),
)),
vec![ModuleRuleEffect::ModuleType(ModuleType::InlinedBytesJs)],
)
}

pub(crate) fn get_import_type_json_rule() -> ModuleRule {
ModuleRule::new(
RuleCondition::ReferenceType(ReferenceType::EcmaScriptModules(
EcmaScriptModulesReferenceSubType::ImportWithType("json".into()),
)),
vec![ModuleRuleEffect::ModuleType(ModuleType::Json)],
)
}

pub(crate) enum EcmascriptTransformStage {
Preprocess,
Main,
Expand Down
2 changes: 1 addition & 1 deletion docs/01-app/03-api-reference/08-turbopack.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Turbopack in Next.js has **zero-configuration** for the common use cases. Below
| **CSS Modules** | **Supported** | `.module.css` files work natively (Lightning CSS). |
| **CSS Nesting** | **Supported** | Lightning CSS supports [modern CSS nesting](https://lightningcss.dev/). |
| **@import syntax** | **Supported** | Combine multiple CSS files. |
| **PostCSS** | **Supported** | Automatically processes `postcss.config.js` in a Node.js worker pool. Useful for Tailwind, Autoprefixer, etc. |
| **PostCSS** | **Supported** | Automatically processes PostCSS config files (`postcss.config.js`, `.mjs`, `.cjs`, `.ts`, `.mts`, `.cts`) in a Node.js worker pool. Useful for Tailwind, Autoprefixer, etc. |
| **Sass / SCSS** | **Supported** (Next.js) | For Next.js, Sass is supported out of the box. Custom Sass functions (`sassOptions.functions`) are not supported because Turbopack's Rust-based architecture cannot directly execute JavaScript functions, unlike webpack's Node.js environment. Use webpack if you need this feature. In the future, Turbopack standalone usage will likely require a loader config. |
| **Less** | Planned via plugins | Not yet supported by default. Will likely require a loader config once custom loaders are stable. |
| **Lightning CSS** | **In Use** | Handles CSS transformations. Some low-usage CSS Modules features (like `:local/:global` as standalone pseudo-classes) are not yet supported. [See below for more details.](#unsupported-and-unplanned-features) |
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "16.2.0-canary.11"
"version": "16.2.0-canary.13"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "16.2.0-canary.11",
"version": "16.2.0-canary.13",
"keywords": [
"react",
"next",
Expand Down
Loading
Loading