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.

reply headers types error

See original GitHub issue

What is the expected behavior?

What is the actual behavior? Upgrading to nock 12.0.1 I get error with this header

const headers: IncomingHttpHeaders = { 'content-type': 'application/json' };
nock('basepath.com')
            .post(`/path`, '{"body": "data"}')
            .once()
            .reply(200, '{"responseBody": "data"}', headers);
Error:(183, 11) TS2769: No overload matches this call.
  Overload 1 of 5, '(statusCode: number, replyBodyFnWithCallback: (this: ReplyFnContext, uri: string, body: Body, callback: (err: ErrnoException | null, result: ReplyBody) => void) => void, headers?: Record<...> | ... 2 more ... | undefined): Scope', gave the following error.
    Argument of type 'string' is not assignable to parameter of type '(this: ReplyFnContext, uri: string, body: Body, callback: (err: ErrnoException | null, result: ReplyBody) => void) => void'.
  Overload 2 of 5, '(statusCode: number, replyBodyFn: (this: ReplyFnContext, uri: string, body: Body) => string | Buffer | Record<string, any> | ReadStream | Promise<...>, headers?: Record<...> | ... 2 more ... | undefined): Scope', gave the following error.
    Argument of type 'string' is not assignable to parameter of type '(this: ReplyFnContext, uri: string, body: Body) => string | Buffer | Record<string, any> | ReadStream | Promise<ReplyBody>'.
  Overload 3 of 5, '(responseCode?: number | undefined, body?: string | Record<string, any> | undefined, headers?: Record<string, ReplyHeaderValue> | Map<string, ReplyHeaderValue> | ReplyHeaderValue[] | undefined): Scope', gave the following error.
    Argument of type 'IncomingHttpHeaders' is not assignable to parameter of type 'Record<string, ReplyHeaderValue> | Map<string, ReplyHeaderValue> | ReplyHeaderValue[] | undefined'.
      **Type 'IncomingHttpHeaders' is not assignable to type 'ReplyHeaderValue[]'.**

Versions

Software Version(s)
Nock ^12.0.1
Node 12.13.0
TypeScript 3.8.2

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mastermattcommented, Feb 25, 2020

I’m assuming IncomingHttpHeaders is from the stdlib http in @types/node, correct?

0reactions
paulmelnikowcommented, May 2, 2020

Thanks @mastermatt, I appreciate the subtlety of your explanation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTP response status codes - MDN Web Docs - Mozilla
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes:
Read more >
How to troubleshoot the error "Failed to process response ...
In almost every event, this error is caused by a connection failure. The error is correct, the service did not receive any response...
Read more >
Rest error message in HTTP Header or Response Body?
Except when responding to a HEAD request, the server SHOULD include an entity containing an explanation of the error situation, and whether it...
Read more >
HTTP/1.1: Response
The response-header fields allow the server to pass additional information about the response which cannot be placed in the Status- Line. These header...
Read more >
HTTP Error 431: 3 Ways to Fix Request Header Fields Too ...
The HTTP Error 431: Request Header Fields Too Large response status code indicates that the origin server refuses to fulfill ... Error type,...
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