Skip to content

Commit d7b051f

Browse files
committed
Merge branch 'main' into conico/fix-stale-cache
2 parents 9bc4ebe + d577521 commit d7b051f

18 files changed

Lines changed: 659 additions & 95 deletions

.changeset/bump-opennextjs-aws.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

.changeset/five-gifts-hope.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

.changeset/fix-peerdeps-next-range.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

.changeset/green-zebras-know.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

.changeset/red-yaks-go.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/cloudflare/CHANGELOG.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,66 @@
11
# @opennextjs/cloudflare
22

3+
## 1.19.3
4+
5+
### Patch Changes
6+
7+
- [#1215](https://github.com/opennextjs/opennextjs-cloudflare/pull/1215) [`608893e`](https://github.com/opennextjs/opennextjs-cloudflare/commit/608893e63e1ee16d07c7ec42da979657cf2a62bd) Thanks [@vicb](https://github.com/vicb)! - Factor large repeated values in manifests
8+
9+
This reduce the size of the generated code.
10+
11+
- [#1218](https://github.com/opennextjs/opennextjs-cloudflare/pull/1218) [`f0d0226`](https://github.com/opennextjs/opennextjs-cloudflare/commit/f0d022685b24881a142bb01005ff78089be8c8d3) Thanks [@314systems](https://github.com/314systems)! - remove `process.version` override
12+
13+
Remove process.version / process.versions.node overrides now that [unjs/unenv#493](https://github.com/unjs/unenv/pull/493) is merged and shipped in [[email protected]](https://github.com/unjs/unenv/releases/tag/v2.0.0-rc.16) (project uses 2.0.0-rc.24)
14+
15+
- [#1199](https://github.com/opennextjs/opennextjs-cloudflare/pull/1199) [`32594d6`](https://github.com/opennextjs/opennextjs-cloudflare/commit/32594d6a921c5ebdbe25f38635bb2c9dabdcbff1) Thanks [@SdSadat](https://github.com/SdSadat)! - fix(cli): fail fast in non-TTY environments instead of hanging on config-creation prompts
16+
17+
When `open-next.config.ts` (or `wrangler.(toml|json|jsonc)`) is missing, the CLI
18+
prompts the user to auto-create it. In non-TTY environments (Cloudflare Workers
19+
Builds, Docker, CI) the Enquirer prompt can't read stdin, so the build hangs or
20+
fails with a truncated prompt and a cryptic exit code — the user sees
21+
`? Missing required open-next.config.ts file, do you want to create one? (Y/n)`
22+
and then ` ELIFECYCLE Command failed with exit code 13`, with no hint at what
23+
to do next.
24+
25+
Now, in non-interactive environments, both prompts throw an actionable error
26+
with the exact template to paste (for `open-next.config.ts`) or point at the
27+
existing `--skipWranglerConfigCheck` / `SKIP_WRANGLER_CONFIG_CHECK` escape
28+
hatch (for the wrangler config). Interactive behavior is unchanged.
29+
30+
## 1.19.2
31+
32+
### Patch Changes
33+
34+
- [#1207](https://github.com/opennextjs/opennextjs-cloudflare/pull/1207) [`0958726`](https://github.com/opennextjs/opennextjs-cloudflare/commit/0958726939d59e4a5c5a3062190278ffdfde38f5) Thanks [@edmundhung](https://github.com/edmundhung)! - bump `@opennextjs/aws` to 3.10.2
35+
36+
See details at <https://github.com/opennextjs/opennextjs-aws/releases/tag/v3.10.2>
37+
38+
- [#1139](https://github.com/opennextjs/opennextjs-cloudflare/pull/1139) [`79b01b8`](https://github.com/opennextjs/opennextjs-cloudflare/commit/79b01b84fd92191517b7a11516c04208f9d474a6) Thanks [@james-elicx](https://github.com/james-elicx)! - Fix Turbopack external module resolution by dynamically discovering external imports at build time.
39+
40+
When packages are listed in `serverExternalPackages`, Turbopack externalizes them via `externalImport()` which uses dynamic `await import(id)`. The bundler (ESBuild) can't statically analyze `import(id)` with a variable, so these modules aren't included in the worker bundle.
41+
42+
This patch:
43+
44+
- Discovers hashed Turbopack external module mappings from `.next/node_modules/` symlinks (e.g. `shiki-43d062b67f27bbdc``shiki`)
45+
- Scans traced chunk files for bare external imports (e.g. `externalImport("shiki")`) and subpath imports (e.g. `shiki/engine/javascript`)
46+
- Generates explicit `switch/case` entries so the bundler can statically resolve and include these modules
47+
48+
- [#1203](https://github.com/opennextjs/opennextjs-cloudflare/pull/1203) [`6f02d12`](https://github.com/opennextjs/opennextjs-cloudflare/commit/6f02d12a75a78410711cc0d9db13ab0d41ed903a) Thanks [@314systems](https://github.com/314systems)! - fix: exclude unsupported Next.js 16 releases from peer dependencies.
49+
50+
The previous range allowed Next.js 16.0.0 through 16.2.2 without a peer dependency warning because `>=16.2.3` was already covered by `>=15.5.15`.
51+
52+
The range now explicitly supports Next.js 15.5.15 and above in the 15.x line, and Next.js 16.2.3 and above in the 16.x line.
53+
54+
- [#1200](https://github.com/opennextjs/opennextjs-cloudflare/pull/1200) [`7820ad0`](https://github.com/opennextjs/opennextjs-cloudflare/commit/7820ad0a0e5f57aba0580f3cabfdd0caa75cc9bb) Thanks [@NathanDrake2406](https://github.com/NathanDrake2406)! - fix: reuse sharded tag data when filling the regional cache.
55+
56+
The sharded tag cache miss path already reads tag data from the Durable Object before answering the request. Reuse that fetched data when populating the regional cache so a shard miss does not immediately trigger a second identical Durable Object read.
57+
58+
- [#1206](https://github.com/opennextjs/opennextjs-cloudflare/pull/1206) [`585795d`](https://github.com/opennextjs/opennextjs-cloudflare/commit/585795dbe20fe20d8662addbf9b7be64d82e3184) Thanks [@314systems](https://github.com/314systems)! - fix: regression where getEnvFromPlatformProxy received wrong options type
59+
60+
This fixes a regression introduced in [32ba91a](https://github.com/opennextjs/opennextjs-cloudflare/commit/32ba91a6d3fa6b9a8b2cd5a8c973c3b3eb1108f0) where `getEnvFromPlatformProxy` call sites passed `OpenNextConfig` even though the function expects Wrangler `GetPlatformProxyOptions`.
61+
62+
The fix restores the pre-[32ba91a](https://github.com/opennextjs/opennextjs-cloudflare/commit/32ba91a6d3fa6b9a8b2cd5a8c973c3b3eb1108f0) argument shape by passing `{ configPath, environment }` from CLI arguments, so env resolution follows the selected Wrangler config/environment.
63+
364
## 1.19.1
465

566
### Patch Changes

packages/cloudflare/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@opennextjs/cloudflare",
33
"description": "Cloudflare builder for next apps",
4-
"version": "1.19.1",
4+
"version": "1.19.3",
55
"type": "module",
66
"scripts": {
77
"clean": "rimraf dist",
@@ -55,6 +55,7 @@
5555
"@ast-grep/napi": "^0.40.5",
5656
"@dotenvx/dotenvx": "catalog:",
5757
"@opennextjs/aws": "3.10.2",
58+
"ci-info": "^4.2.0",
5859
"cloudflare": "^4.4.1",
5960
"comment-json": "^4.5.1",
6061
"enquirer": "^2.4.1",

packages/cloudflare/src/api/overrides/tag-cache/do-sharded-tag-cache.spec.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ describe("DOShardedTagCache", () => {
271271

272272
it("should only read tag data once on a regional-cache miss", async () => {
273273
const putMock = vi.fn();
274-
// @ts-expect-error - Defined on cloudfare context
274+
// @ts-expect-error - Defined on cloudflare context
275275
globalThis.caches = {
276276
open: vi.fn().mockResolvedValue({
277277
match: vi.fn().mockResolvedValue(null),
@@ -294,7 +294,7 @@ describe("DOShardedTagCache", () => {
294294
"http://local.cache/shard/tag-hard;shard-1?tag=tag1",
295295
expect.any(Response)
296296
);
297-
// @ts-expect-error - Defined on cloudfare context
297+
// @ts-expect-error - Defined on cloudflare context
298298
globalThis.caches = undefined;
299299
});
300300

@@ -445,15 +445,15 @@ describe("DOShardedTagCache", () => {
445445
});
446446

447447
it("should try to return the cache instance if regional cache is enabled", async () => {
448-
// @ts-expect-error - Defined on cloudfare context
448+
// @ts-expect-error - Defined on cloudflare context
449449
globalThis.caches = {
450450
open: vi.fn().mockResolvedValue("cache"),
451451
};
452452
const cache = shardedDOTagCache({ baseShardSize: 4, regionalCache: true });
453453
expect(cache.localCache).toBeUndefined();
454454
expect(await cache.getCacheInstance()).toBe("cache");
455455
expect(cache.localCache).toBe("cache");
456-
// @ts-expect-error - Defined on cloudfare context
456+
// @ts-expect-error - Defined on cloudflare context
457457
globalThis.caches = undefined;
458458
});
459459
});
@@ -470,7 +470,7 @@ describe("DOShardedTagCache", () => {
470470
});
471471

472472
it("should call .match on the cache", async () => {
473-
// @ts-expect-error - Defined on cloudfare context
473+
// @ts-expect-error - Defined on cloudflare context
474474
globalThis.caches = {
475475
open: vi.fn().mockResolvedValue({
476476
match: vi.fn().mockResolvedValue(new Response("1234567")),
@@ -486,13 +486,13 @@ describe("DOShardedTagCache", () => {
486486
expect(cacheResult.length).toBe(1);
487487
// "1234567" is a plain number (old format) → backward-compat parse
488488
expect(cacheResult[0]).toEqual({ tag: "tag1", revalidatedAt: 1234567, stale: 1234567, expire: null });
489-
// @ts-expect-error - Defined on cloudfare context
489+
// @ts-expect-error - Defined on cloudflare context
490490
globalThis.caches = undefined;
491491
});
492492

493493
it("should parse new JSON object format from the cache", async () => {
494494
const stored = JSON.stringify({ revalidatedAt: 1000, stale: 500, expire: 9999 });
495-
// @ts-expect-error - Defined on cloudfare context
495+
// @ts-expect-error - Defined on cloudflare context
496496
globalThis.caches = {
497497
open: vi.fn().mockResolvedValue({
498498
match: vi.fn().mockResolvedValue(new Response(stored)),
@@ -502,7 +502,7 @@ describe("DOShardedTagCache", () => {
502502
const doId = new DOId({ baseShardId: "shard-1", numberOfReplicas: 1, shardType: "hard" });
503503
const cacheResult = await cache.getFromRegionalCache({ doId, tags: ["tag1"] });
504504
expect(cacheResult[0]).toEqual({ tag: "tag1", revalidatedAt: 1000, stale: 500, expire: 9999 });
505-
// @ts-expect-error - Defined on cloudfare context
505+
// @ts-expect-error - Defined on cloudflare context
506506
globalThis.caches = undefined;
507507
});
508508
});
@@ -521,7 +521,7 @@ describe("DOShardedTagCache", () => {
521521

522522
it("should put the tags in the regional cache if the tags exists in the DO", async () => {
523523
const putMock = vi.fn();
524-
// @ts-expect-error - Defined on cloudfare context
524+
// @ts-expect-error - Defined on cloudflare context
525525
globalThis.caches = {
526526
open: vi.fn().mockResolvedValue({
527527
put: putMock,
@@ -543,13 +543,13 @@ describe("DOShardedTagCache", () => {
543543
"http://local.cache/shard/tag-hard;shard-1?tag=tag1",
544544
expect.any(Response)
545545
);
546-
// @ts-expect-error - Defined on cloudfare context
546+
// @ts-expect-error - Defined on cloudflare context
547547
globalThis.caches = undefined;
548548
});
549549

550550
it("should not put the tags in the regional cache if the tags does not exists in the DO", async () => {
551551
const putMock = vi.fn();
552-
// @ts-expect-error - Defined on cloudfare context
552+
// @ts-expect-error - Defined on cloudflare context
553553
globalThis.caches = {
554554
open: vi.fn().mockResolvedValue({
555555
put: putMock,
@@ -568,13 +568,13 @@ describe("DOShardedTagCache", () => {
568568

569569
expect(getTagDataMock).toHaveBeenCalledWith(["tag1"]);
570570
expect(putMock).not.toHaveBeenCalled();
571-
// @ts-expect-error - Defined on cloudfare context
571+
// @ts-expect-error - Defined on cloudflare context
572572
globalThis.caches = undefined;
573573
});
574574

575575
it("should put multiple tags in the regional cache", async () => {
576576
const putMock = vi.fn();
577-
// @ts-expect-error - Defined on cloudfare context
577+
// @ts-expect-error - Defined on cloudflare context
578578
globalThis.caches = {
579579
open: vi.fn().mockResolvedValue({
580580
put: putMock,
@@ -603,13 +603,13 @@ describe("DOShardedTagCache", () => {
603603
"http://local.cache/shard/tag-hard;shard-1?tag=tag2",
604604
expect.any(Response)
605605
);
606-
// @ts-expect-error - Defined on cloudfare context
606+
// @ts-expect-error - Defined on cloudflare context
607607
globalThis.caches = undefined;
608608
});
609609

610610
it("should put missing tag in the regional cache if `regionalCacheDangerouslyPersistMissingTags` is true", async () => {
611611
const putMock = vi.fn();
612-
// @ts-expect-error - Defined on cloudfare context
612+
// @ts-expect-error - Defined on cloudflare context
613613
globalThis.caches = {
614614
open: vi.fn().mockResolvedValue({
615615
put: putMock,
@@ -635,13 +635,13 @@ describe("DOShardedTagCache", () => {
635635
"http://local.cache/shard/tag-hard;shard-1?tag=tag1",
636636
expect.any(Response)
637637
);
638-
// @ts-expect-error - Defined on cloudfare context
638+
// @ts-expect-error - Defined on cloudflare context
639639
globalThis.caches = undefined;
640640
});
641641

642642
it("should not put missing tag in the regional cache if `regionalCacheDangerouslyPersistMissingTags` is false", async () => {
643643
const putMock = vi.fn();
644-
// @ts-expect-error - Defined on cloudfare context
644+
// @ts-expect-error - Defined on cloudflare context
645645
globalThis.caches = {
646646
open: vi.fn().mockResolvedValue({
647647
put: putMock,
@@ -664,7 +664,7 @@ describe("DOShardedTagCache", () => {
664664

665665
expect(getTagDataMock).toHaveBeenCalledWith(["tag1"]);
666666
expect(putMock).not.toHaveBeenCalled();
667-
// @ts-expect-error - Defined on cloudfare context
667+
// @ts-expect-error - Defined on cloudflare context
668668
globalThis.caches = undefined;
669669
});
670670
});

0 commit comments

Comments
 (0)