Skip to content

Commit

Permalink
Add streaming capabilities to "inngest/cloudflare" handler (#311)
Browse files Browse the repository at this point in the history
## Summary
<!-- Succinctly describe your change, providing context, what you've
changed, and why. -->

Adds streaming capabilities to to the `"inngest/cloudflare"` serve
handler.

## Checklist
<!-- Tick these items off as you progress. -->
<!-- If an item isn't applicable, ideally please strikeout the item by
wrapping it in "~~"" and suffix it with "N/A My reason for skipping
this." -->
<!-- e.g. "- [ ] ~~Added tests~~ N/A Only touches docs" -->

- [ ] ~Added a [docs PR](https://github.com/inngest/website) that
references this PR~ N/A
- [ ] ~Added unit/integration tests~ N/A
- [x] Added changesets if applicable
  • Loading branch information
jpwilliams authored Oct 21, 2024
1 parent 7ca9537 commit a53356a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/slimy-gorillas-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"inngest": patch
---

Add streaming capabilities to `"inngest/cloudflare"` handler
8 changes: 7 additions & 1 deletion packages/inngest/src/cloudflare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const frameworkName: SupportedFrameworkName = "cloudflare-pages";
* Expected arguments for a Cloudflare Pages Function.
*/
export type PagesHandlerArgs = [
{ request: Request; env: Record<string, string | undefined> },
{ request: Request; env: Record<string, string | undefined> }
];

/**
Expand Down Expand Up @@ -150,6 +150,12 @@ export const serve = (
headers,
});
},
transformStreamingResponse: ({ body, status, headers }) => {
return new Response(body, {
status,
headers,
});
},
};
},
});
Expand Down
1 change: 1 addition & 0 deletions packages/inngest/src/helpers/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ const streamingChecks: Partial<
* See {@link https://vercel.com/docs/frameworks/nextjs#streaming}
*/
vercel: (_framework, _env) => typeof EdgeRuntime === "string",
"cloudflare-pages": () => true,
};

export const getPlatformName = (env: Env) => {
Expand Down

0 comments on commit a53356a

Please sign in to comment.