-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add a cloudflare-streaming wrapper #642
Conversation
🦋 Changeset detectedLatest commit: 1e9aa86 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Coverage Report
File Coverage
|
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would make more sense to use cloudflare-server
instead of cloudflare-streaming
.
The other one support streaming as well, it's just that it only works with next edge
runtime.
Even better we could rename the other one cloudflare-edge
and this one cloudflare-node
which would allow people to understand more easily which one to use depending on the runtime they use
env: Record<string, string>, | ||
ctx: any, | ||
): Promise<Response> => { | ||
globalThis.process = process; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this be necessary to import process here ?
Something like import * as process from 'node:process';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
process
is a global in node compat mode so I think this should be dropped entirely. This code would only make sense when not in node compat mode.
wrapper: handler, | ||
name: "cloudflare-streaming", | ||
supportStreaming: true, | ||
edgeRuntime: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure what the value should be here.
My take is that it should be false as this is used for the edge
runtime of next which is not the use case for this wrapper.
If that's the way we decide to pursue, we should add a check in the validation of the config file to throw an error for people using edgeRuntime
wrapper without runtime: "edge"
in their config
It won't have any effect anyway if used on a "node" route
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this value without paying too much attention but I agree it should be false.
Great idea. I'll do that (and alias the former "cloudflare" to "cloudflare-edge" for BC! |
@conico974 do you think we could merge this PR as is and I would address the comments in a follow up early next week. The rationale is that I have a pending opennextjs/opennextjs-cloudflare#140 using this and I think if I push here it might update the pre-release and break that PR (not sure if the version changes or not). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we can merge it's fine. Thanks
@conico974 Do you think "cloudflare-streaming" is a reasonable name or "cloudflare-server" would be better (or any other idea)?
The changes are somehow tested - might require minor tweaks later.
I have spread the changes across different commits per unit of work to ease the review.
Thanks!