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

POST request hanging #1150

Closed
JackFazackerley opened this issue Dec 24, 2020 · 47 comments
Closed

POST request hanging #1150

JackFazackerley opened this issue Dec 24, 2020 · 47 comments

Comments

@JackFazackerley
Copy link

Bug Report

Current Behavior
Making POST requests to serverless-offline hangs forever but GET requests work as expected.

  • file: serverless.yml
service: test

frameworkVersion: '2'

provider:
  name: aws
  runtime: go1.x
  apiGateway:
    shouldStartNameWithService: true

package:
  individually: true
  exclude:
    - ./**

functions:
  hello:
    handler: bin/hello
    package:
      include:
        - ./bin/hello
    events:
      - http:
          path: hello
          method: ANY

plugins:
  - serverless-offline
  • file: hello/main.go
package main

import (
	"encoding/json"

	"github.com/aws/aws-lambda-go/events"
	"github.com/aws/aws-lambda-go/lambda"
)

// BodyRequest is our self-made struct to process JSON request from Client
type BodyRequest struct {
	RequestName string `json:"name"`
}

// BodyResponse is our self-made struct to build response for Client
type BodyResponse struct {
	ResponseName string `json:"name"`
}

// Handler function Using AWS Lambda Proxy Request
func Handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {

	// BodyRequest will be used to take the json response from client and build it
	bodyRequest := BodyRequest{
		RequestName: "",
	}

	// Unmarshal the json, return 404 if error
	err := json.Unmarshal([]byte(request.Body), &bodyRequest)
	if err != nil {
		return events.APIGatewayProxyResponse{Body: err.Error(), StatusCode: 404}, nil
	}

	// We will build the BodyResponse and send it back in json form
	bodyResponse := BodyResponse{
		ResponseName: bodyRequest.RequestName + " LastName",
	}

	// Marshal the response into json bytes, if error return 404
	response, err := json.Marshal(&bodyResponse)
	if err != nil {
		return events.APIGatewayProxyResponse{Body: err.Error(), StatusCode: 404}, nil
	}

	//Returning response with AWS Lambda Proxy Response
	return events.APIGatewayProxyResponse{Body: string(response), StatusCode: 200}, nil
}

func main() {
	lambda.Start(Handler)
}

Expected behavior/code
Should be able to POST. I have tried with other handlers other than Go and the result is the same.

Environment

  • serverless version: 2.16.1

  • serverless-offline version: 6.8.0

  • node.js version: v15.5.0

  • OS: macOS 10.15.7

  • go version: v1.15.6

@JackFazackerley
Copy link
Author

It turns out node v15.5.0 was the issue. I downgraded to node v15.4.0 and it works as expected for POST.

@scottenock
Copy link

scottenock commented Jan 2, 2021

Thanks @JackFazackerley, you've saved me such a headache! Should this issue not remain open though? As it's quite a breaking bug, and a notice should at least be added to the readme file to spare anyone else having issues with this.

@JackFazackerley
Copy link
Author

@scottenock I'm glad it helped! I guess it should actually, got ahead of myself at the time! Will reopen.

@will-holley
Copy link

Encountered this after a fresh install on a new machine. Very frustrating. Thanks for this.

@kenberkeley
Copy link

Only v15.5.x is not working. Please upgrade/downgrade Node version to solve this issue.

@sverrejb
Copy link

Running Node v.16.0.0 here, and I have this problem.

1 similar comment
@heynikhil
Copy link

Running Node v.16.0.0 here, and I have this problem.

@iamrutvik
Copy link

Works well on Node 15.14.0. Tested. Managing it via NVM

@sushilprj
Copy link

I have a similar issue with Node v16.1.0.

@mcgalcode
Copy link

I am using Node v16.2.0 and I also have this problem.

@F94Olivera
Copy link

I am using Node v16.2.0 just like @mcgalcode and have this problem as well

@bitsofinfo
Copy link

getting the same

@M1kep
Copy link

M1kep commented Jun 13, 2021

Adding to this, node 16.3.0 also broken(As is probably expected)

@deepakchinnadurai
Copy link

i have the same issue my get request is working fine but my post method is not working

@deepakchinnadurai
Copy link

just uninstall version 16 and install v10 node it works

@tehsc2
Copy link

tehsc2 commented Jun 21, 2021

Works well on Node v14.17.0

@savez
Copy link

savez commented Jun 23, 2021

Works well on Node v14.7.0

@DSubhadipSahoo
Copy link

Not working with Node 16.0.0 and NPM 7.10.0

@imyuvii
Copy link

imyuvii commented Jun 28, 2021

Not working with Node 16.4.0, Downgraded to 15.4.0 and worked! Thank you @JackFazackerley

@brunocalderon
Copy link

brunocalderon commented Jul 2, 2021

Related to #1151
Not working with node 16.4.1
Downgraded to node 14.17.2 via homebrew 🍺

@Wakk0
Copy link

Wakk0 commented Jul 5, 2021

Not working with 14.17.2 on linux (debian)

@luisdemarchi
Copy link

not working with v16.4.2 (homebrew)
downgraded to 15.4.0:

npm install -g n
sudo n 15.4.0
brew uninstall --ignore-dependencies node
node -v                                  

@ganey
Copy link
Contributor

ganey commented Jul 13, 2021

Not working on v14.17.0 on linux (ubuntu)

@dmontecillo
Copy link

dmontecillo commented Jul 21, 2021

Works on 14.15.5 just make sure that the below items 2 and 3 items are the same.
This is my setup:

  1. serverless.yml - runtime: nodejs14.x
  2. launch.json - runtimeExecutable: /Users/{me}/.nvm/versions/node/v14.15.5/bin/npm
  3. system - {use command which node} = /Users/{me}/.nvm/versions/node/v14.15.5/bin/node

@malkaviano
Copy link

Why are tickets being closed? Reverting to node 14 is not the solution and all ticket just refer to each other with no 'official' response.

Are you at least thinking about suporting the new node?

Thanks.

@trygveaa
Copy link

trygveaa commented Aug 6, 2021

@malkaviano: Because it's been fixed. See #1235 and https://github.com/dherault/serverless-offline/releases/tag/v8.0.0.

@slatermorgan
Copy link

slatermorgan commented Oct 6, 2021

I still have this issue with v16.10.0

Just to confirm downgrading to v15.4.0 fixed this issue, clearly this issue still exists

@trygveaa
Copy link

trygveaa commented Oct 6, 2021

@slatermorgan: Which version of serverless-offline are you using? It works fine for me with node v16.10.0 and serverless-offline v8.2.0.

@slatermorgan
Copy link

@trygveaa !
Framework Core: 2.28.0 (local)
Plugin: 4.4.3
SDK: 2.3.2
Components: 3.7.1

@trygveaa
Copy link

@slatermorgan: None of those are the version of serverless-offline.

@7evam
Copy link

7evam commented Oct 12, 2021

I tried making a post request with node version 16.11.1 and serverless-offline version 6.8.0 and got a hanging request. Then I tried with node version 15.4.0 and serverless-offline version 6.8.0 and the request went through. Then I upgraded serverless-offline to version 8.2.0 and changed back to node version 16.11.1 and the request went through.

So the updated version of serverless-offline fixed the problem for me

@lucaseverest
Copy link

With node version 16.9.0 and serverless-offline version 7.1.0 i had the same error. Then I upgraded serverless-offline to version 8.2.0 and it resolve the problem :)

@slatermorgan
Copy link

With node version 16.9.0 and serverless-offline version 7.1.0 i had the same error. Then I upgraded serverless-offline to version 8.2.0 and it resolve the problem :)

Yes sorry, silly me! Upgrading my serverless-offline fixed this issue

@hanchiang
Copy link

With node version 16.9.0 and serverless-offline version 7.1.0 i had the same error. Then I upgraded serverless-offline to version 8.2.0 and it resolve the problem :)

Thanks for the solution! Spent many hours searching just about anything.

@aj-n
Copy link

aj-n commented Jan 20, 2022

With node version 16.9.0 and serverless-offline version 7.1.0 i had the same error. Then I upgraded serverless-offline to version 8.2.0 and it resolve the problem :)

Confirming upgrading worked for me as well (node v16.13.0, serverless 7.0.0 -> 8.3.1)

@zcaceres
Copy link

Same issue on Node 16.3. Reinstall serverless and serverless-offline to latest versions.

@sguha-work
Copy link

I also faced the same issue on nodejs v 16.4 LTS and in latest 17 version, downgraded my local node to 15.4 and every post request is running as it should

@karamsingh90
Copy link

The easy solution is just updated dependencies.

npm update

Mainly this issue due to 2 reasons

  • Serverless offline version
  • Node version
    When both become UpToDate. It will work smoothly.

@asifj
Copy link

asifj commented Mar 23, 2022

Issue still does not seem to be fixed with node v17.7.2. I had to downgrade to v 15.14 to make it work.

@trygveaa
Copy link

Issue still does not seem to be fixed with node v17.7.2. I had to downgrade to v 15.14 to make it work.

Please don't keep posting here without making sure you use the most recent version of serverless-offline. The fix is in serverless-offline, not in node.

@nasatome
Copy link

nasatome commented Apr 1, 2022

image

image

image

error :( in docker w/alpine

@anhnlh
Copy link

anhnlh commented Jun 14, 2022

Still happens with node v18.3.0. Downgraded to v15.4.0 worked for me, using n.

Remove node installed with brew because it's going to interfere with n

@dnalborczyk
Copy link
Collaborator

closing this issue as it's quite old. if this is still a problem for anyone, please open a new issue and provide repro steps.

@piyushvyas9
Copy link

It turns out node v15.5.0 was the issue. I downgraded to node v15.4.0 and it works as expected for POST.

You saved my time. Thanks @JackFazackerley

@amanprak
Copy link

Yep, not working with the latest node too...had to downgrade it

@samartomar
Copy link

ANy solution to this beside downgrade which i can not do, as have other things that need latest version.

@dnalborczyk
Copy link
Collaborator

@amanprak @samartomar #1150 (comment) literally nothing is gonna happen otherwise

Repository owner locked and limited conversation to collaborators Jul 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests