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.

TypeError: rawRequest.connection.address is not a function

See original GitHub issue

Description

We are using a library that uses a Popsicle client.

There is a failure in mocking the requests using Popsicle.

Shareable Source

Pretty vanilla Polly setup:

import path from 'path'
import { Polly, PollyServer } from '@pollyjs/core'
import NodeHttpAdapter from '@pollyjs/adapter-node-http'
import FSPersister from '@pollyjs/persister-fs'

Polly.register(FSPersister)
Polly.register(NodeHttpAdapter)

export class PollyJS {
  recordingName: string
  polly: Polly

  constructor(recordingName: string) {
    this.recordingName = recordingName
    this.polly = new Polly(this.recordingName, {
      adapters: ['node-http'],
      persister: 'fs',
      persisterOptions: {
        fs: {
          recordingsDir: path.resolve(__dirname, '../__recordings__'),
        },
      },
    })
  }

  getPollyInstance(): Polly {
    return this.polly
  }

  getPollyServer(): PollyServer {
    return this.polly.server
  }
}

Error Message & Stack Trace

    TypeError: rawRequest.connection.address is not a function

      at OverriddenClientRequest.onResponse (node_modules/popsicle-transport-http/src/index.ts:316:33)
      at _respond (node_modules/nock/lib/request_overrider.js:525:17)
      at respond (node_modules/nock/lib/request_overrider.js:508:11)

The code can be found here: https://github.com/serviejs/popsicle-transport-http/blob/ef78022e431532ec710c716ca91b7d3691afe888/src/index.ts#L316

Config

See above.

Dependencies

Copy the @pollyjs dependencies from package.json:

{
    "@pollyjs/adapter-node-http": "2.6.3",
    "@pollyjs/core": "2.6.3",
    "@pollyjs/persister-fs": "2.6.3"
}

Relevant Links

Provided by @nguyentoanit: https://github.com/nguyentoanit/popsicle-polly-error

Environment

Tell us which operating system you are using, as well as which versions of Node.js and npm/yarn. If applicable, include the browser and the corresponding version.

Run the following to get it quickly:

Node.js v10.15.3
darwin 18.7.0
npm 6.11.3

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
mastermattcommented, Oct 31, 2019

This was fixed in Nock as of 11.7.0

2reactions
offirgolancommented, Oct 20, 2019

@moltar the best thing to do would be to open a PR to nock. We can also patch it on our end in the mean time but #264 needs to be addressed first.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: app.address is not a function using chai-http
chai.request(app) doesn't accept a fastify instance as input as documented: You may use a function (such as an express or connect app) or...
Read more >
update socket class with missing address method · Issue #1643
update socket class with missing address method #1643 ... TypeError: rawRequest.connection.address is not a function Netflix/pollyjs#263.
Read more >
HTTP | Node.js v19.3.0 Documentation
When a connection is closed by the client or the server, it is removed from the pool. Any unused sockets in the pool...
Read more >
Express body-parser middleware
The type option is used to determine what media type the middleware will parse. This option can be a string, array of strings,...
Read more >
TypeScript - Fastify
TypeScript. The Fastify framework is written in vanilla JavaScript, and as such type definitions are not as easy to maintain; however, since version...
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