Skip to content
This repository has been archived by the owner on Jun 11, 2020. It is now read-only.

Error: could not handle the request #31

Open
montanaflynn opened this issue Feb 27, 2018 · 10 comments
Open

Error: could not handle the request #31

montanaflynn opened this issue Feb 27, 2018 · 10 comments

Comments

@montanaflynn
Copy link

Getting this plain text response every 30 or so requests:

Error: could not handle the request

Checking the server logs I found this:

severity:  "ERROR"  
textPayload:  "Error: function crashed out of request scope
 Function invocation was interrupted.
" 
@iangudger
Copy link
Contributor

There are no known issues that would cause this. Are you sure that it isn't a bug in your app?

@montanaflynn
Copy link
Author

montanaflynn commented Feb 27, 2018

I never get the error when testing with (make test) or making the handler from the golang net/http server. I did find a similar issue: firebase/functions-samples#78 but that's for javascript.

My handler encodes a png image and writes it to http.ResponseWriter, here's the entire app.

Here is more error information from the logs:

Function execution took 284 ms, finished with status: 'connection error'

@iangudger
Copy link
Contributor

Can you try removing the use of the nodego logger and see if that fixes the problem?

By the way, when you add the logging back, you should add the nodego.WithLoggerFunc middleware. That way your logs will get associated with the request that triggered them. See examples/logging.go.

@montanaflynn
Copy link
Author

montanaflynn commented Feb 27, 2018

Removing the nodego logger does seem to fix the issue.

The problem remains even when using the nodego.WithLoggerFunc middleware. When using the middleware should I not use nodego.ErrorLogger.Println(err)? If I use Go's std log then I miss out on the error / info abstraction.

@montanaflynn
Copy link
Author

Nevermind the problem remains even without the logs, just took over a hundred requests before it happened.

https://gist.github.com/montanaflynn/bb002f8212e9cc7f75af5cc03e7a5fd8

...
HTTP/1.1 200     3.66 secs:    7742 bytes ==> GET  /img-without-logs
HTTP/1.1 500     3.68 secs:      36 bytes ==> GET  /img-without-logs
HTTP/1.1 200     0.84 secs:    7742 bytes ==> GET  /img-without-logs
...

@montanaflynn
Copy link
Author

montanaflynn commented Feb 27, 2018

I removed any third party packages and can reproduce with standard library:

This code returns the error / 500 response every so often.
This code does not return an error / 500 response afaik.

The difference in the code that doesn't return an error is I removed all the nodego logger code including init nodego.OverrideLogger() and nodego.WithLoggerFunc middleware wrapper.

@iangudger
Copy link
Contributor

It seems that the problem could still be logging as you include nodego.OverrideLogger() in the problematic one, but not the non-problematic one.

@iangudger
Copy link
Contributor

By the way, you can use nodego.ErrorLogger with nodego.WithLoggerFunc. Maybe we need to clarify the documentation.

@marcelogrsp
Copy link

Hi all, I am getting the same error.
It works when Testing but doesn't work when I send HTTP POST request.
Actually it works via POST request after I send 3 or more requests.

@iangudger
Copy link
Contributor

Cloud Functions now has official Go support:
https://cloud.google.com/functions/docs/quickstart#functions-update-install-gcloud-go

As a result, this repository is no longer under active development. Pull requests are still welcome though.

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

4 participants