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
14 changes: 12 additions & 2 deletions examples/api/open-next.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import type { OpenNextConfig } from "@opennextjs/aws/types/open-next";

const config: OpenNextConfig = {
default: {},
default: {
override: {
wrapper: "cloudflare-node",
converter: "edge",
// Unused implementation
incrementalCache: "dummy",
tagCache: "dummy",
queue: "dummy",
},
},

middleware: {
external: true,
override: {
wrapper: "cloudflare",
wrapper: "cloudflare-edge",
converter: "edge",
proxyExternalRequest: "fetch",
},
},
};
Expand Down
2 changes: 1 addition & 1 deletion examples/api/wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#:schema node_modules/wrangler/config-schema.json
name = "api"
main = ".open-next/index.mjs"
main = ".open-next/worker.ts"
compatibility_date = "2024-09-23"
compatibility_flags = ["nodejs_compat"]

Expand Down
14 changes: 12 additions & 2 deletions examples/create-next-app/open-next.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import type { OpenNextConfig } from "@opennextjs/aws/types/open-next";

const config: OpenNextConfig = {
default: {},
default: {
override: {
wrapper: "cloudflare-node",
converter: "edge",
// Unused implementation
incrementalCache: "dummy",
tagCache: "dummy",
queue: "dummy",
},
},

middleware: {
external: true,
override: {
wrapper: "cloudflare",
wrapper: "cloudflare-edge",
converter: "edge",
proxyExternalRequest: "fetch",
},
},
};
Expand Down
2 changes: 1 addition & 1 deletion examples/create-next-app/wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#:schema node_modules/wrangler/config-schema.json
name = "create-next-app"
main = ".open-next/index.mjs"
main = ".open-next/worker.ts"

compatibility_date = "2024-09-23"
compatibility_flags = ["nodejs_compat"]
Expand Down
14 changes: 12 additions & 2 deletions examples/vercel-blog-starter/open-next.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import type { OpenNextConfig } from "@opennextjs/aws/types/open-next";

const config: OpenNextConfig = {
default: {},
default: {
override: {
wrapper: "cloudflare-node",
converter: "edge",
// Unused implementation
incrementalCache: "dummy",
tagCache: "dummy",
queue: "dummy",
},
},

middleware: {
external: true,
override: {
wrapper: "cloudflare",
wrapper: "cloudflare-edge",
converter: "edge",
proxyExternalRequest: "fetch",
},
},
};
Expand Down
2 changes: 1 addition & 1 deletion examples/vercel-blog-starter/wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#:schema node_modules/wrangler/config-schema.json
name = "vercel-blog-starter-on-workers"
main = ".open-next/index.mjs"
main = ".open-next/worker.ts"

compatibility_date = "2024-09-23"
compatibility_flags = ["nodejs_compat"]
Expand Down
16 changes: 13 additions & 3 deletions examples/vercel-commerce/open-next.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import type { OpenNextConfig } from '@opennextjs/aws/types/open-next';

const config: OpenNextConfig = {
default: {},
default: {
override: {
wrapper: 'cloudflare-node',
converter: 'edge',
// Unused implementation
incrementalCache: 'dummy',
tagCache: 'dummy',
queue: 'dummy'
}
},

middleware: {
external: true,
override: {
wrapper: 'cloudflare',
converter: 'edge'
wrapper: 'cloudflare-edge',
converter: 'edge',
proxyExternalRequest: 'fetch'
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion examples/vercel-commerce/wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#:schema node_modules/wrangler/config-schema.json
name = "vercel-commerce-on-workers"
main = ".open-next/index.mjs"
main = ".open-next/worker.ts"

compatibility_date = "2024-09-23"
compatibility_flags = ["nodejs_compat"]
Expand Down
10 changes: 6 additions & 4 deletions packages/cloudflare/src/cli/build/bundle-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@ fetch = globalThis.fetch;
const CustomRequest = class extends globalThis.Request {
constructor(input, init) {
if (init) {
delete init.cache;
if (init.body?.__node_stream__ === true) {
init = {
...init,
cache: undefined,
// https://github.com/cloudflare/workerd/issues/2746
init.body = __cf_stream.Readable.toWeb(init.body);
}
// https://github.com/cloudflare/workerd/issues/3245
body: init.body instanceof __cf_stream.Readable ? ReadableStream.from(init.body) : init.body,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would this fail if init.body is a Readable from unenv ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From the top of my head I would say no.
It works with Node (/undici) only because a Readable is async iterable.
And we moved away from unenv Readable because it does not implement async iterator.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was thinking about user code actually, since this is overriding the global Request, user code or one of their lib could be using unenv or similar and instanceof would be false

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, got it now.

There should be no more instances of unenv Readable after unjs/unenv#363 (cloudflare/workerd#3245 has some details). Before that it was still possible to create an unenv Readable via the http module.

};
}
super(input, init);
}
Expand Down
28 changes: 14 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ catalog:
"tsx": ^4.19.2
"typescript-eslint": ^8.7.0
"vitest": ^2.1.1
"wrangler": ^3.93.0
"wrangler": ^3.95.0
Loading