Skip to content

Download continues after maxContentLength exceeded #1098

Closed
@nornagon

Description

@nornagon

#### Summary

The following code demonstrates the issue:

require('axios').get(
  'https://upload.wikimedia.org/wikipedia/commons/f/fe/A_Different_Slant_on_Carina.jpg',
  { maxContentLength: 2000 }
)
  .then(d => console.log('done'))
  .catch(e => console.log(e.toString()))

Expected behavior:

  • The script exits immediately after printing "Error: maxContentLength size of 2000 exceeded"
  • Not much more than 2KB was downloaded from the server

Actual behavior:

  • The script prints "Error: maxContentLength size of 2000 exceeded", then continues to download the remaining 52MB of data from the server. It takes about two minutes before it exits on my connection.

It's possible to work around this by adding a cancellation token and manually canceling the request when an error is encountered. However, since the request never actually fires a "complete" event, it's surprising that the download continues, only to have the data be thrown into the void.

#### Context

  • axios version: v0.16.2
  • Environment: node v8.4.0, macOS Sierra 10.12.6

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