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

fix: cloudflare waitUntil not working as inteded with getRuntime #7419

Merged
merged 5 commits into from
Jun 20, 2023

Conversation

TorbjornHoltmon
Copy link
Contributor

Changes

What does this change?

  • The cloudflare context was spread. This did not work and waitUntil was not passed on as intended.
    ( This might also be an issue for other context runtime functions )
  • Wait until has to be "proxied" through a function, passing the reference alone will trigger illegal invocations.

Testing

Tested on our own environment.
Has been tested on our advanced mode website.
I cannot speak for directory mode, but I assume the problem is the same.

Docs

No need to update docs, waitUntil should now work as intended.

Comments

I did not bother to mock waitUntil since we already have a mock In our project.

Its up to the Astro team to decide from this point on. But you could do something like what we do:

    waitUntil: (promise: Promise<any>) => {
      if (runtime?.waitUntil) {
        runtime.waitUntil(promise);
      } else {
        Promise.resolve(promise).catch((error) => {
          console.error(error);
          // noop
        });
      }
    },

@changeset-bot
Copy link

changeset-bot bot commented Jun 19, 2023

🦋 Changeset detected

Latest commit: f88085e

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

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 the pkg: integration Related to any renderer integration (scope) label Jun 19, 2023
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
@ematipico ematipico merged commit 94afaa3 into withastro:main Jun 20, 2023
@astrobot-houston astrobot-houston mentioned this pull request Jun 20, 2023
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