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

Support for Firebase Functions #1358

Closed
RobertSasak opened this issue Aug 20, 2023 · 5 comments
Closed

Support for Firebase Functions #1358

RobertSasak opened this issue Aug 20, 2023 · 5 comments
Labels
enhancement New feature or request.

Comments

@RobertSasak
Copy link
Contributor

What is the feature you are proposing?

I think Deno is a perfect to be used as a dynamic router in Firebase functions. Currently Express is the main choise.

Firebase function expect (request, reponse)=>void function which should not be so difficult to provide from Deno. I have looked into nodejs-server implementaion but I might need some more hints.

@RobertSasak RobertSasak added the enhancement New feature or request. label Aug 20, 2023
@RobertSasak
Copy link
Contributor Author

It was not so hard in the end. Import node-server package and use getRequestListener around app.fetch.

import { getRequestListener } from '@hono/node-server'
import { onRequest } from 'firebase-functions/v2/https'
import { Hono } from 'hono'

const app = new Hono()
app.get('/**', (c) => c.text('Hello Node.js!'))

export const web = onRequest(getRequestListener(app.fetch))

@yusukebe
Copy link
Member

Great!

@RobertSasak
Copy link
Contributor Author

There is an silent error 500 when doing a POST request with payload.

TypeError: Response body object should not be disturbed or locked
    at extractBody (node:internal/deps/undici/undici:6433:17)
    at new Request (node:internal/deps/undici/undici:7314:48)
    at /<path>/functions/node_modules/@hono/node-server/dist/listener.js:48:33
    at /<path>/functions/lib/functions/src/index.js:79:64
    at /<path>/functions/node_modules/firebase-functions/lib/v2/providers/https.js:57:29
    at cors (/<path>/functions/node_modules/cors/lib/index.js:188:7)
    at /<path>/functions/node_modules/cors/lib/index.js:224:17
    at originCallback (/<path>/functions/node_modules/cors/lib/index.js:214:15)
    at /<path>/functions/node_modules/cors/lib/index.js:219:13
    at optionsCallback (/<path>/functions/node_modules/cors/lib/index.js:199:9)

It is exactly the same error as in honojs/node-server#84

@yusukebe
Copy link
Member

@RobertSasak

Could you create the issue on honojs/node-server issues with the minimal code for reproduce it?

@RobertSasak
Copy link
Contributor Author

Yes, lets move conversation to #1695

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request.
Projects
None yet
Development

No branches or pull requests

2 participants