Giter VIP home page Giter VIP logo

Comments (10)

busma13 avatar busma13 commented on July 29, 2024 1

It could definitely be got not emitting end. I will look into that. Thanks @mikicho

from nock.

matt-boris avatar matt-boris commented on July 29, 2024 1

Hey @busma13, have you gotten any further with this? We're having a similar issue on taskcluster while trying to upgrade to the latest version of node.

from nock.

mikicho avatar mikicho commented on July 29, 2024

@busma13 any chance the regression is in got side? from what I see, handleEnd is never get called.

from nock.

busma13 avatar busma13 commented on July 29, 2024

@matt-boris No I haven't, we were okay with disabling the test because the function was covered well in e2e testing, so it lost priority. I wanted to search through the got issues to see if someone else had a similar problem before making my own, but I never finished that. Are you using got to make requests as well?

from nock.

matt-boris avatar matt-boris commented on July 29, 2024

@busma13 yes, we're using got as well.

from nock.

stephen-willoughby avatar stephen-willoughby commented on July 29, 2024

I think this is a got issue and not a nock issue as I did a quick switch to use axios instead of got and it worked

UPDATE: this was using got v13.0.0

from nock.

stephen-willoughby avatar stephen-willoughby commented on July 29, 2024
const nock = require('nock')
const fs = require('fs')
const axios = require('axios')

const myFile = 'somefile.txt'
const host = 'http://example.com'
const path = '/some/path'
const response = { foo: 'bar' }
const options = {
  method: 'post',
  url: host + path,
  body: fs.createReadStream(myFile)
}

nock(host)
  .post(path)
  .reply(200, response)

const run = async () => {
  const { default: got } = await import('got')

  try {
    const result = await got(options)
    console.log(result.body)
  } catch (error) {
    console.error('error')
    console.error(error)
  }
  console.log('complete')
}

run()

As a minimal recreate. The oddness is that if I switch the url to https://httpbin.org/post it works, but if I switch got to axios it works too. Almost as if it's the combination of the two

from nock.

mikicho avatar mikicho commented on July 29, 2024

Thanks for verifying this!
Can we close this one?

from nock.

busma13 avatar busma13 commented on July 29, 2024

Thanks @stephen-willoughby
Yeah I'll close this.

from nock.

stephen-willoughby avatar stephen-willoughby commented on July 29, 2024

Any chance this could be reopened?

got aren't interested in addressing it. And it seems to specifically be around the use of both got and nock. On sindresorhus/got#2341 someone has suggested a workaround, with a patch of nock, but I've no idea of its validity

from nock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.