question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

delayBody doesn't trigger timeout or sockettimeout unlike testing against an actual http server

See original GitHub issue

When I run https://github.com/request/request against an actual HTTP server that delays closing the HTTP request after sending headers, I get a timeout or socket timeout. When I run it against nock configured to perform a delayBody with the same time, I do not get a timeout or socket timeout.

Take a look at https://github.com/jeffcharles/nock-timeout-testcase for an executable example. Running it on my machine results in:

Request sent back error: Error: ESOCKETTIMEDOUT
Nock should have failed with timeout but didn't

How can I configure Nock to timeout the socket given headers being sent back but the response not having been ended?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:6
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
srkimircommented, Apr 10, 2016

+1

i believe i tried same thing, following code will return then block should not execute: Hello from Google! while i would expect ETIMEDOUT

mocha test/force-req-timeout.test.js --timeout=10000

'use strict'

const chai = require('chai')
const expect = chai.expect
const nock = require('nock')
const rp = require('request-promise')

describe('force request timeout with nock', () => {
  it('should return ETIMEDOUT', (done) => {

    nock('http://www.google.com')
    .get('/')
    .delay(8000)
    .reply(200, 'Hello from Google!')

    rp({
      url: 'http://www.google.com',
      timeout: 5000
    })
    .then((data) => {
      console.log('then block should not execute: ', data)
      ...
    })
    .catch((err) => {
      expect(err.cause.code).to.equal('ETIMEDOUT')
      ...
    })
  })
})

http://stackoverflow.com/questions/36533807/how-to-etimedout-with-nock-and-request-library

1reaction
gr2mcommented, Apr 4, 2018

👋 @hugoduraes Pedro is not maintaining nock any longer, I’m trying my best to help out (and onboard new maintainers hint hint). I’m on vacation right now, I can look into it after April 22. If anyone would like to send a PR, happy to review it after unless someone beats me to it 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

MockWebServer response delay - testing timeouts
I'm trying to test HTTP timeout scenarios using a MockWebServer which answers my test ... delayBody and . ... This doesnt return a...
Read more >
Common Timeouts effecting Web Services, HTTP and SOAP ...
Use the ConnectionIOTimeOut property to specify the maximum amount of time, in seconds, that the J2EE server waits for the complete HTTP ......
Read more >
Make resilient Go net/http servers using timeouts, deadlines ...
If the operation does not complete in the given time limit, a timeout occurs, and the operation is canceled. Initializing a net/http server...
Read more >
Apache Http Client and Asynchronous HTTP client timeouts ...
As the usual explanation that “the connection timeout is the maximum time to establish a connection to the server” is not the most...
Read more >
How to Get to the Bottom of Network Timeout Issues
Keywords could be in one of several different forms. Some of these may be: "SocketTimeOut", "Read timed out", and "Request timeout".
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found