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

TypeError: self.response.abort is not a function #1953

Closed
ctricot opened this issue Dec 8, 2015 · 4 comments
Closed

TypeError: self.response.abort is not a function #1953

ctricot opened this issue Dec 8, 2015 · 4 comments

Comments

@ctricot
Copy link

ctricot commented Dec 8, 2015

The code to generate the error :

request("http://migre.me/sgP5Z", function (error, response, body) {
})

After some investigation I found that the redirection generate a bad URI :

Url {
  protocol: 'http:',
  slashes: true,
  auth: null,
  host: '',
  port: null,
  hostname: '',
  hash: null,
  search: null,
  query: null,
  pathname: '//iusnatura.com.br/meio-ambiente/cop-21-pode-resultar-em-acordo-historico-para-conter-aquecimento-global/%27',
  path: '//iusnatura.com.br/meio-ambiente/cop-21-pode-resultar-em-acordo-historico-para-conter-aquecimento-global/%27',
  href: 'http:////iusnatura.com.br/meio-ambiente/cop-21-pode-resultar-em-acordo-historico-para-conter-aquecimento-global/%27' }

Any idea to avoid this issue ?

Thanks

@simov
Copy link
Member

simov commented Dec 9, 2015

This is how the request looks like:

{ request: 
   { debugId: 1,
     uri: 'http://migre.me/sgP5Z',
     method: 'GET',
     headers: { host: 'migre.me' } } }
{ redirect: 
   { debugId: 1,
     statusCode: 301,
     headers: 
      { date: 'Wed, 09 Dec 2015 15:20:35 GMT',
        server: 'Apache/2.2.14 (Ubuntu)',
        'x-powered-by': 'PHP/5.3.2-1ubuntu4.30',
        'set-cookie': [Object],
        location: 'http:////iusnatura.com.br/meio-ambiente/cop-21-pode-resultar-em-acordo-historico-para-conter-aquecimento-global/',
        connection: 'close',
        'content-length': '0',
        vary: 'Accept-Encoding',
        'content-type': 'text/html; charset=utf-8' },
     uri: 'http:////iusnatura.com.br/meio-ambiente/cop-21-pode-resultar-em-acordo-historico-para-conter-aquecimento-global/' } }

So it seems they have an extra pair of // in their location header. It's obviously a server issue and request is not that fault tolerant.

@ctricot
Copy link
Author

ctricot commented Dec 9, 2015

Thanks for your answer.

Any idea to "catch" the error ?

BR

@simov
Copy link
Member

simov commented Dec 10, 2015

request("http://migre.me/sgP5Z", function (error, response, body) {

})
.on('error', function (err) {
  console.log(err)
})

But currently there is a bug in request as well. I just pushed a fix here: #1958

@ctricot
Copy link
Author

ctricot commented Dec 10, 2015

Thanks but with theses method "on('error'" don't catch the error. I will apply the patch.

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

No branches or pull requests

2 participants