Skip to content

Port multiple PRs from source repositories#26

Merged
conico974 merged 28 commits intomainfrom
conico/port-cloudflare
Mar 29, 2026
Merged

Port multiple PRs from source repositories#26
conico974 merged 28 commits intomainfrom
conico/port-cloudflare

Conversation

@conico974
Copy link
Copy Markdown
Contributor

Ported several pull requests from the OpenNext.js Cloudflare repositories, including updates to skills, bug fixes, and improvements to various commands.

conico974 added 26 commits March 8, 2026 14:46
opennextjs/opennextjs-cloudflare#1122

Applied bugfixes and improvements to the 'migrate' command:
- Fixed extra newlines when appending to files (updated conditionalAppendFileSync signature)
- Fixed error when 'public' directory is missing (creates parent directories automatically)
- Fixed Next.js config file update to check if the file exists first
- Updated checkRunningInsideNextjsApp to accept { appPath: string } instead of full BuildOptions

Changesets:
- .changeset/port-pr-1122-cloudflare.md
- .changeset/port-pr-1122-aws.md
opennextjs/opennextjs-cloudflare#1126

Fix: prevent Worker hang on HEAD requests to static assets

When run_worker_first is enabled, HEAD requests to static assets hang
the Worker because response.body is null (per HTTP spec) and the
fallback new ReadableStream() creates a stream that never closes.

Changes:
- Return null body for HEAD requests instead of falling through to
the hanging ReadableStream fallback
- Add tests for maybeGetAssetResult covering GET, HEAD, 404, POST,
and run_worker_first=false cases

Changeset: .changeset/port-pr-1126.md
opennextjs/opennextjs-cloudflare#1133

Changeset: .changeset/port-pr-1133.md

Update the migrate command to attempt to create an R2 bucket for caching
as part of the migration process, if that is not possible an application
without caching enabled will be generated instead.
opennextjs/opennextjs-cloudflare#1147

make dev /cdn-cgi/image behaves like prod for consistency

Changeset: .changeset/port-pr-1147.md
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 21, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@opennextjs/cloudflare@26
npm i https://pkg.pr.new/@opennextjs/aws@26

commit: 3ba5da2

Copy link
Copy Markdown
Collaborator

@james-elicx james-elicx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like the other, only had a brief skim through since it's a lift and shift

Comment on lines +67 to +77
pnpm code:checks 2>&1 | tail -20
```

This runs formatting, linting, and TypeScript checks.
This runs formatting, linting, and TypeScript checks. Only the tail of the output is shown to see the result.

### 7. Run Unit Tests

After code checks pass, run only the unit tests from the tests-unit package:

```bash
pnpm --filter tests-unit test
pnpm --filter tests-unit test 2>&1 | tail -20
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personally i wouldn't include the 2>&1 | tail -20 in the snippet - most will reach for that out-of-the-box depending on what they're doing, so inlining might make them do it in cases where they might have gone for a different approach.

Suggested change
pnpm code:checks 2>&1 | tail -20
```
This runs formatting, linting, and TypeScript checks.
This runs formatting, linting, and TypeScript checks. Only the tail of the output is shown to see the result.
### 7. Run Unit Tests
After code checks pass, run only the unit tests from the tests-unit package:
```bash
pnpm --filter tests-unit test
pnpm --filter tests-unit test 2>&1 | tail -20
pnpm code:checks

This runs formatting, linting, and TypeScript checks. Only the tail of the output is shown to see the result.

7. Run Unit Tests

After code checks pass, run only the unit tests from the tests-unit package:

pnpm --filter tests-unit test

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good call, I used a bunch of different AI to test them on that and some were very dumb 😄

Base automatically changed from conico/port-skills to main March 29, 2026 16:18
Copilot AI review requested due to automatic review settings March 29, 2026 16:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR ports multiple upstream OpenNext Cloudflare changes into this monorepo, primarily expanding the Cloudflare CLI (including a new migrate flow), updating templates, and aligning adapter behavior/tests with newer Next.js and Wrangler requirements.

Changes:

  • Add/extend Cloudflare CLI capabilities (new migrate command, stricter yargs handling, improved wrangler passthrough + helpers).
  • Update Cloudflare templates and image handling (dev /cdn-cgi/image/* support, wrangler.jsonc templating, config generation utilities).
  • Update adapter/runtime behavior and tests (asset resolver HEAD handling, cache handler test coverage, dependency bumps).

Reviewed changes

Copilot reviewed 63 out of 65 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
pnpm-lock.yaml Bumps OpenNext Cloudflare/AWS and adds dependencies (incl. comment-json).
packages/tests-unit/tests/adapters/cache.test.ts Adds cache handler unit test for Next 15+ app cache entries.
packages/open-next/src/build/helper.ts Changes checkRunningInsideNextjsApp signature to accept { appPath }.
packages/cloudflare/templates/wrangler.jsonc Makes template placeholders for compat date + bucket name.
packages/cloudflare/src/cli/utils/normalize-path.ts Adds cross-platform path normalizer.
packages/cloudflare/src/cli/utils/nextjs-support.ts Adds Next.js/Wrangler compatibility checks.
packages/cloudflare/src/cli/utils/needs-experimental-react.ts Moves/duplicates helper for experimental react detection.
packages/cloudflare/src/cli/utils/extract-project-env-vars.ts Removes large doc comment; keeps env var extraction logic.
packages/cloudflare/src/cli/utils/create-wrangler-config.ts Adds wrangler.jsonc creation + optional R2 bucket setup.
packages/cloudflare/src/cli/utils/create-open-next-config.ts Adds open-next config file creation helper.
packages/cloudflare/src/cli/utils/ask-account-selection.ts Adds interactive Cloudflare account selection (Enquirer).
packages/cloudflare/src/cli/templates/worker.ts Refactors /cdn-cgi/image/* dev handling into helper.
packages/cloudflare/src/cli/templates/images.ts Adds CDN-CGI parsing/handler + refactors header reading.
packages/cloudflare/src/cli/templates/images.spec.ts Adds tests for CDN-CGI parsing + content-type detection.
packages/cloudflare/src/cli/project-options.ts Fixes WranglerTarget import path.
packages/cloudflare/src/cli/index.ts Adds strict/help/version/fail behavior + registers migrate.
packages/cloudflare/src/cli/commands/utils/utils.ts Refactors config compilation + wrangler passthrough arg handling.
packages/cloudflare/src/cli/commands/utils/utils.spec.ts Adds unit tests for compileConfig behavior.
packages/cloudflare/src/cli/commands/utils/run-wrangler.ts Refactors wrangler runner to return {success,stdout,stderr}.
packages/cloudflare/src/cli/commands/utils/helpers.ts Moves env-from-proxy + shell quoting into utils module.
packages/cloudflare/src/cli/commands/utils/files.ts Adds conditional append helper used by migrate.
packages/cloudflare/src/cli/commands/upload.ts Updates wrangler invocation + adds error handling + passthrough args.
packages/cloudflare/src/cli/commands/skew-protection.ts Fixes helper import path.
packages/cloudflare/src/cli/commands/preview.ts Updates wrangler invocation + adds error handling + passthrough args.
packages/cloudflare/src/cli/commands/populate-cache.ts Updates imports + wrangler invocation + adds error handling + passthrough args.
packages/cloudflare/src/cli/commands/populate-cache.spec.ts Updates mocks/import paths for moved wrangler/helpers.
packages/cloudflare/src/cli/commands/migrate.ts Adds new migrate command implementation.
packages/cloudflare/src/cli/commands/helpers.ts Removes old helpers module (moved to utils).
packages/cloudflare/src/cli/commands/deploy.ts Updates wrangler invocation + adds error handling + passthrough args.
packages/cloudflare/src/cli/commands/build.ts Updates wrangler config creation flow; exports buildCommand; passthrough args.
packages/cloudflare/src/cli/commands/build.spec.ts Adds tests for wrangler config creation prompt flow.
packages/cloudflare/src/cli/build/utils/needs-experimental-react.ts Removes outdated commentary from existing helper.
packages/cloudflare/src/cli/build/utils/index.ts Removes barrel export file.
packages/cloudflare/src/cli/build/utils/extract-project-env-vars.spec.ts Removes old unit tests (file relocated).
packages/cloudflare/src/cli/build/utils/create-config-files.ts Removes older config creation utilities (replaced by new ones).
packages/cloudflare/src/cli/build/patches/plugins/wrangler-external.ts Updates normalizePath import location.
packages/cloudflare/src/cli/build/patches/plugins/route-module.ts Updates normalizePath import location.
packages/cloudflare/src/cli/build/patches/plugins/next-server.ts Updates normalizePath import location.
packages/cloudflare/src/cli/build/patches/plugins/load-manifest.ts Updates normalizePath import location.
packages/cloudflare/src/cli/build/patches/plugins/instrumentation.ts Updates normalizePath import location.
packages/cloudflare/src/cli/build/patches/plugins/dynamic-requires.ts Updates normalizePath import location.
packages/cloudflare/src/cli/build/open-next/createServerBundle.ts Updates normalizePath import source.
packages/cloudflare/src/cli/build/open-next/compile-env-files.ts Updates extractProjectEnvVars import source.
packages/cloudflare/src/cli/build/bundle-server.ts Refactors util imports (normalizePath + split barrel).
packages/cloudflare/src/cli/build/build.ts Uses ensureNextjsVersionSupported from new utils module.
packages/cloudflare/src/api/overrides/incremental-cache/regional-cache.ts Adjusts regional cache behavior/docs around purge + defaults.
packages/cloudflare/src/api/overrides/asset-resolver/index.ts Fixes HEAD handling to avoid hanging stream; refactors body selection.
packages/cloudflare/src/api/overrides/asset-resolver/index.spec.ts Adds tests covering GET/HEAD body behavior and gating conditions.
packages/cloudflare/package.json Adds comment-json + @types/comment-json dev dep.
create-cloudflare/next/wrangler.jsonc Updates starter wrangler.jsonc compatibility_date placeholder.
create-cloudflare/next/package.json Bumps starter dependency to @opennextjs/cloudflare ^1.17.1.
.claude/skills/port-pr/SKILL.md Updates porting instructions (tail output, staging/commit flow).
.changeset/port-pr-1150.md Adds changeset for ported upstream PR.
.changeset/port-pr-1147.md Adds changeset for ported upstream PR.
.changeset/port-pr-1146.md Adds changeset for ported upstream PR.
.changeset/port-pr-1142.md Adds changeset for ported upstream PR.
.changeset/port-pr-1138.md Adds changeset for ported upstream PR.
.changeset/port-pr-1133.md Adds changeset for ported upstream PR.
.changeset/port-pr-1127.md Adds changeset for ported upstream PR.
.changeset/port-pr-1126.md Adds changeset for ported upstream PR.
.changeset/port-pr-1122-cloudflare.md Adds changeset + summary for migrate-related fixes.
.changeset/port-pr-1122-aws.md Adds changeset documenting helper signature change.
.changeset/port-pr-1105.md Adds changeset for ported upstream PR.
.changeset/port-pr-1097.md Adds changeset for ported upstream PR.
.changeset/port-pr-1083.md Adds changeset for ported upstream PR.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@conico974 conico974 merged commit af85bba into main Mar 29, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants