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

abortcontroller & request.clone issue with fetch #2227

Closed
KhafraDev opened this issue Aug 25, 2023 · 0 comments · Fixed by #3169
Closed

abortcontroller & request.clone issue with fetch #2227

KhafraDev opened this issue Aug 25, 2023 · 0 comments · Fixed by #3169
Labels
bug Something isn't working

Comments

@KhafraDev
Copy link
Member

KhafraDev commented Aug 25, 2023

  import { Request } from 'undici'
  import { ok, strictEqual } from 'node:assert'

  const controller = new AbortController();
  const signal = controller.signal;

  const request = new Request('http://a', { signal });
  const clonedRequest = request.clone();

  const log = [];

  request.signal.addEventListener('abort', () => log.push('original-aborted'));
  clonedRequest.signal.addEventListener('abort', () => log.push('clone-aborted'));

  controller.abort();

  strictEqual(log, ['original-aborted', 'clone-aborted'], "Abort events fired in correct order");
  ok(request.signal.aborted, 'Signal aborted');
  ok(clonedRequest.signal.aborted, 'Signal aborted');

cc @atlowChemi since you recently made a PR regarding abortcontroller, hopefully you can help. I don't know enough about EventTarget and order of events to fix this

@KhafraDev KhafraDev added the bug Something isn't working label Aug 25, 2023
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