Skip to content

generic: fetch overrides existing request.waitUntil #306

Description

@pi0x

The generic adapter's fetch always replaces request.waitUntil with its own implementation (Object.defineProperties(request, { waitUntil: ... })), even when the request already has one. When the generic adapter wraps a handler on a platform like Cloudflare or Vercel, the platform's waitUntil is lost and promises go to an internal set that nothing awaits.

import { serve } from "srvx/generic";

const server = serve({ fetch: () => new Response("ok") });
const req = new Request("http://localhost/");
req.waitUntil = (p) => platformContext.waitUntil(p);
await server.fetch(req);
req.waitUntil; // generic adapter's waitUntil, not the platform one

Nitro hit this while applying server entry middleware/plugins on serverless presets (nitrojs/nitro#4620 follow-up). The suggested fix is to only define waitUntil when the request does not already have one.

Reported with AI assistance.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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