Skip to content

await fetch cache set dangling promise #736

Closed
@dario-piotrowicz

Description

@dario-piotrowicz

Next.js sets values in the incremental cache for fetch calls: https://github.com/vercel/next.js/blob/e5fc495e3d4/packages/next/src/server/lib/patch-fetch.ts#L690-L728

The issue here is that this promise is never awaited in the Next.js code (since in a standard node.js server
the promise will eventually simply just run) but when run in a Cloudflare worker it should be run it inside waitUntil
(so that the worker is not killed before the promise is fully executed), without that this promise gets discarded and values
don't get saved in the incremental cache.

Some patch should be applied here so that the dangling promise is instead properly awaited, the same has been done
in the Cloudflare adapter here: opennextjs/opennextjs-cloudflare#364
(the same sort of fix should be applied here and opennextjs/opennextjs-cloudflare#364 reverted since the cloudflare adatper will simply inherit the patch)


original discussion

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions