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

Pact client doesn't send DELETE requests with body correctly #183

Closed
jnazander opened this issue Sep 18, 2019 · 9 comments
Closed

Pact client doesn't send DELETE requests with body correctly #183

jnazander opened this issue Sep 18, 2019 · 9 comments

Comments

@jnazander
Copy link

jnazander commented Sep 18, 2019

Software versions

  • OS: Windows 10
  • Library version: 9.0.4
  • Node Version: 10.15.3

Expected behaviour

Pact mock client during pact provider tests should send HTTP DELETE requests with HTTP body correctly.

Actual behaviour

It doesn't send HTTP DELETE requests correctly.

I'm using Node.js with Express framework as the server, and I'm running pact provider tests / pact verifications. One of the pact interactions is a DELETE request that has a request body (The spec does not forbid it). All other requests go through fine, but the delete request seemingly makes the server freeze and not return anything until the timeout, at which it resets the HTTP connection (see the pact provider log attached).

Upon further investigation with Wireshark I found out the underlying problem: the pact mock client doesn't even send all of the TCP packets that make up the HTTP DELETE request - it stops short of sending the body. This makes the server wait for the remaining packet, which never comes, thus hanging the test until it times out.

image

Interestingly, it does send Content-Length: 15 in the first packet, indicating that there will be a body in the following packet(s), but it never sends it.

Steps to reproduce

Try to verify a pact with the following interaction:

{
      "description": "A DELETE request to delete one reminder",
      "providerState": "User user1@example.com exists with 2 smart reminders",
      "request": {
        "method": "DELETE",
        "path": "/api/users/22/schedule",
        "headers": {
          "Content-Type": "application/json",
        },
        "body": {
          "items": [
            100
          ]
        }
      },
      "response": {
        "status": 204,
        "headers": {
        }
      }
    }

(or any pact that has a HTTP DELETE method with a request body).

Relevant log files

Log file generated by pact provider test attached.
pact-provider.log

@jnazander
Copy link
Author

Also, I understand that it's not the Pact library's fault, but one of the underlying HTTP client. But I'm having a hard time figuring out which one. Is it request, @types/request or some other?

@TimothyJones
Copy link
Contributor

pact-node wraps the pact-standalone ruby implementation, so I suspect that is the culprit (a quick stackoverflow search suggests that many ruby http clients don't support delete with bodies).

You might want to open an issue on pact-ruby. (@bethesque - is that the right place? I'm surprised we haven't hit this before).

@TimothyJones
Copy link
Contributor

@jnazander can you confirm that this issue exists if you call pact-provider-verifier directly?

$ node_modules/.bin/pact-provider-verifier

you can see the options with

$ node_modules/.bin/pact-provider-verifier --help

@jnazander
Copy link
Author

@TimothyJones
I checked with pact-provider-verifier directly and it does the same thing, sending the first packet, waiting a few minutes and then timing out with EOFError:

Failures:

  1) Verifying a pact between mobile-app and app-api-delete-test Given User user1@example.com exists with 2 smart reminders A DELETE request to delete one reminder with DELETE /api/users/22/schedule returns a response which has status code 204
     Failure/Error: replay_interaction interaction, options[:request_customizer]

     EOFError:
       end of file reached


1 interaction, 1 failure

Failed interactions:

* A delete request to delete one reminder given User user1@example.com exists with 2 smart reminders

@jnazander
Copy link
Author

Created an issue in pact-ruby - pact-foundation/pact-ruby#198

@TimothyJones
Copy link
Contributor

Thanks. That means the issue definitely lies with the ruby implementation.

I'm not sure whether the right place to raise it is pact-provider-verifier or pact-ruby. Can you open an issue over on one of those?

I'll leave this issue open because we'll need to upgrade the pact-standalone version once it is fixed.

@TimothyJones
Copy link
Contributor

Nice, our messages crossed. Thanks for being so proactive!

@TimothyJones
Copy link
Contributor

Releasing v10.2.4, which should have a fixed version of pact-standalone. Let us know how you go

@bethesque
Copy link
Member

Someone else had this issue recently, and I told them I didn't think it could be fixed. Will have to do a search of all the issues and try and track it down.

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

3 participants