Skip to content
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 SSR adaptor for cloudflare pages functions #3600

Merged
merged 1 commit into from
Jun 16, 2022

Conversation

nrgnrg
Copy link
Contributor

@nrgnrg nrgnrg commented Jun 15, 2022

Changes

  • Add an SSR adaptor for Cloudflare Pages functions.

Notes

There is 1 change within the Astro server runtime which was necessary to make this work, 'serialize-javascript' generates a random number at the top level of the module, this is a pattern which is forbidden by Cloudflare workers. The error given is this:

Uncaught Error: Some functionality, such as asynchronous I/O, timeouts, and generating random values, can only be performed while handling a request. at line 0 (Code: 10021)

The fix is dynamically importing the dependency so that it generates the random number at call time, even when inlined in the build.

Testing

Docs

@changeset-bot
Copy link

changeset-bot bot commented Jun 15, 2022

🦋 Changeset detected

Latest commit: 699382c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/cloudflare Minor

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

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope) labels Jun 15, 2022
@nrgnrg nrgnrg force-pushed the feat/pages-functions-adaptor branch from 5ae8ea4 to e94044c Compare June 15, 2022 07:34
Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

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

Hey @nrgnrg! This is great work, just one note on the change to serializeProps. Probably not necessary anymore. 😉

packages/astro/src/runtime/server/hydration.ts Outdated Show resolved Hide resolved
@nrgnrg nrgnrg force-pushed the feat/pages-functions-adaptor branch from e94044c to 699382c Compare June 15, 2022 16:52
@github-actions github-actions bot removed the pkg: astro Related to the core `astro` package (scope) label Jun 15, 2022
@nrgnrg
Copy link
Contributor Author

nrgnrg commented Jun 15, 2022

@natemoo-re I've removed the serializeProps changes 🙂

@nrgnrg nrgnrg requested a review from natemoo-re June 15, 2022 16:53
Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for the PR!

@matthewp matthewp merged commit 7f42358 into withastro:main Jun 16, 2022
@github-actions github-actions bot mentioned this pull request Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: integration Related to any renderer integration (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants