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

gRPC connect-es support #278

Open
rogersgt opened this issue Jun 14, 2023 · 0 comments
Open

gRPC connect-es support #278

rogersgt opened this issue Jun 14, 2023 · 0 comments

Comments

@rogersgt
Copy link
Contributor

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Issue

I'm using serverless-http with express, and @bufbuild/connect-express to support a gRPC-compatible HTTP api on AWS Lambda and API Gateway. It may not be a super common use case, but we liked the idea of a lightweight backend; and also enjoy the type benefits of leveraging gRPC protocol syntax.

We noticed that copying the same code that runs just fine on a traditional express server with this gRPC adapter library was executing code successfully; however the response was never sent. The write method buf connect uses should actually return a boolean indicating whether the function should wait for a drain event or not, but the custom write method serverless-http defines doesn't return anything; but also doesn't provide a drain event, and so this leads to the hang.

Solution

Simply having the assignSocket method in the response.js file return a boolean value solved this issue for us. If this interferes with any other use case behavior, any assistance in resolving this issue in the preferred way would be very helpful. Thank you in advance!

diff --git a/node_modules/serverless-http/lib/response.js b/node_modules/serverless-http/lib/response.js
index da745c4..f3bf74c 100644
--- a/node_modules/serverless-http/lib/response.js
+++ b/node_modules/serverless-http/lib/response.js
@@ -124,6 +124,7 @@ module.exports = class ServerlessResponse extends http.ServerResponse {
         if (typeof cb === 'function') {
           cb();
         }
+        return true;
       },
     });
 

This issue body was partially generated by patch-package.

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

1 participant