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

cancelling fetch after promise has been resolved #1282

Closed
ronag opened this issue Aug 9, 2021 · 1 comment
Closed

cancelling fetch after promise has been resolved #1282

ronag opened this issue Aug 9, 2021 · 1 comment

Comments

@ronag
Copy link
Contributor

ronag commented Aug 9, 2021

Given my current understand of the spec the following unit test (from node-fetch) should always fail:

it('should reject response body methods immediately with AbortError when aborted before stream is disturbed', () => {
  return expect(fetch(
    `${base}slow`,
    { signal: controller.signal }
  ))
    .to.eventually.be.fulfilled
    .then(res => {
      controller.abort()
      return expect(res.text())
        .to.eventually.be.rejected
        .and.be.an.instanceof(Error)
        .and.have.property('name', 'AbortError')
    })
})

The response is cancelled before res.text() starts reading from the response body and given the current way ReadableStream.cancel works we will just read an empty string as success. There is no propagation of the abort error to the reader of the response stream.

Refs: nodejs/node#39715

@ronag ronag closed this as completed Aug 9, 2021
@ronag ronag reopened this Aug 9, 2021
@ronag ronag closed this as completed Aug 10, 2021
@ronag
Copy link
Contributor Author

ronag commented Aug 10, 2021

Use controller.error.

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

No branches or pull requests

1 participant