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

undici.Request.clone does not copy dispatcher #3630

Closed
berndfuhrmann opened this issue Sep 20, 2024 · 0 comments · Fixed by #3631
Closed

undici.Request.clone does not copy dispatcher #3630

berndfuhrmann opened this issue Sep 20, 2024 · 0 comments · Fixed by #3631
Labels
bug Something isn't working

Comments

@berndfuhrmann
Copy link

Bug Description

Reproducible By

Consider this code:

async function test() {
    const undici = require('undici');

    class CustomAgent extends undici.Agent {
        constructor() {
            super({
                keepAliveTimeout: 10,
                keepAliveMaxTimeout: 10
            });
        }
        dispatch(options, handler) {
            console.log("DISPATCH");
            return super.dispatch(options, handler);
        }
    }

    const request = new undici.Request("https://example.org", {
        dispatcher: new CustomAgent()
    });

    // will make an HTTP call and print "DISPATCH"
    await undici.fetch(request);

    // will make an HTTP call, but not print "DISPATCH"
    await undici.fetch(request.clone());
}

test();

Expected Behavior

In the code above, I would expect both fetch calls to use the dispatcher.

Logs & Screenshots

none.

Environment

NodeJS, Version v22.9.0

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant