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

TypeError: _onRequestWithOpts is not a function #1480

Closed
joeponzio opened this issue Jul 9, 2019 · 35 comments · Fixed by #1482
Closed

TypeError: _onRequestWithOpts is not a function #1480

joeponzio opened this issue Jul 9, 2019 · 35 comments · Fixed by #1482

Comments

@joeponzio
Copy link

[REQUIRED] Environment info

firebase-tools: 7.0.2

Platform: macOS

[REQUIRED] Test case

npm i -g firebase-tools@latest or
npm i -D firebase-tools@latest

[REQUIRED] Steps to reproduce

Error encountered: TypeError: _onRequestWithOpts is not a function at Object.httpsProvider._onRequestWithOpts (in lib/emulator/functionsEmulatorRuntime.js)

  1. Init a new project with Firebase init, choose location, and set up functions in the dashboard
  2. Updated global package, ran firebase run serve, and encountered the error
  3. Deleted the global package, installed locally to project, ran firebase run serve, and encountered the error
  4. Console logged const httpsProvider = require(httpsProviderResolution); in the above file and the path outputted is lib/providers/https which does not exist.

(Note: Functions local emulator worked prior to step #2 when I tried to update firebase-tools.)

[REQUIRED] Expected behavior

Run functions locally.

[REQUIRED] Actual behavior

functions: Emulator started at http://localhost:5000
i functions: Watching "/Users/joe/Server/my-project/functions" for Cloud Functions...
⚠ TypeError: _onRequestWithOpts is not a function
at Object.httpsProvider._onRequestWithOpts (/Users/joe/Server/my-project/functions/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:278:24)
at Object.httpsProvider.onRequest (/Users/joe/Server/my-project/functions/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:283:34)
at Object. (/Users/joe/Server/my-project/functions/index.js:18:38)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:683:19)
at require (internal/modules/cjs/helpers.js:16:16)
at /Users/joe/Server/my-project/functions/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:582:33
⚠ We were unable to load your functions code. (see above)

@lcarbonaro
Copy link

lcarbonaro commented Jul 9, 2019

Experiencing the exact same issue. All was well day before yesterday. Thanks for posting this - I've been racking my brains trying to figure out what I've done wrong that would have broken my little project. Tried reverting to version 7.0.0 of firebase-tools but still got the same error. firebase deploy seems to work fine; it's firebase serve that gives the error.

@merlinnot
Copy link
Contributor

I've opened a PR to fix it, see #1482.

@hendrikswan
Copy link

I'm also running into this issue.

@mmillerscsu
Copy link

Literally having the same issue. Tried just running the hello world program and gives the same error if using firebase serve. Good to know I'm not the only one.

@samtstern
Copy link
Contributor

Thanks all for reporting and @merlinnot for the fix! That's what we get for relying on internal APIs

@mmillerscsu
Copy link

anyone else getting an unexpected error, when trying to run firebase serve with the hello world program?

@lcarbonaro
Copy link

lcarbonaro commented Jul 9, 2019

Yes @mmillerscsu . First got this error last night. Was working on an existing project, so my first thought was: I screwed up something. A few hours later, I decided to create a project from scratch and that's when I noticed that even the helloWorld function on a brand new project gives the same errror on trying to run firebase serve. Then this morning I saw this thread.

@samtstern
Copy link
Contributor

If you are experiencing this issue, the workaround is to run npm install firebase-functions@3.0.2 in your functions directory.

@lcarbonaro
Copy link

Thanks @samtstern Any ETA on when this will be fixed though?

@samtstern
Copy link
Contributor

#1482 is already underway, this should be fixed by the end of the day.

@lcarbonaro
Copy link

lcarbonaro commented Jul 9, 2019

If anyone needs a quick fix for this issue, I just tried workaround suggested by @samtstern and firebase serve now works fine. Thanks again @samtstern

@mmillerscsu
Copy link

@samtstern got it to work thanks! I will be using this temporarily until they update the fix.

@lcarbonaro
Copy link

@lcarbonaro did you run firebase init first, and then firebase-functions?

@mmillerscsu No I just ran npm install firebase-functions@3.0.2 in the functions folder as @samtstern suggested.

@mmillerscsu
Copy link

@lcarbonaro got it to work now thanks.

@jheredia
Copy link

jheredia commented Jul 9, 2019

Thanks @samtstern for the workaround, that helped me.

@lefnire
Copy link

lefnire commented Jul 9, 2019

I tried installing 3.0.2 & firebase/firebase-functions#master (per the ref'd merged PR), and still getting that error in both cases. Maybe another dep in the mix causing issues? I'm:

"actions-on-google": "^2.8.0",
"firebase-admin": "^8.2.0",
"firebase-functions": "3.0.2",
"firebase-functions-test": "^0.1.6",

@jheredia
Copy link

jheredia commented Jul 9, 2019

@lefnire Same error message? I have the same dependencies on my functions package.json but the only error that I got it was from grpc that made me update the node version to 10.

@lefnire
Copy link

lefnire commented Jul 9, 2019

@jheredia scratch that, I nuked node_modules & functions/node_modules tried again, all good

@abhay994
Copy link

Delete node_modules then run npm install, npm install firebase-admin and npm install firebase-functions@3.0.2

@converge
Copy link

npm install firebase-functions@3.0.1 (not 3.0.2) worked for me

@samtstern
Copy link
Contributor

samtstern commented Jul 12, 2019 via email

@DouglasGMoore
Copy link

no it hasnt been fixed

@dcts
Copy link

dcts commented Jul 13, 2019

Fixed it for me when i run npm install firebase-functions@3.0.2 inside functions as described in this stackoverflow answer

@Myolisi
Copy link

Myolisi commented Jul 15, 2019

npm install firebase-functions@3.0.2 fixed it for me

@manh-gntvn
Copy link

Use node ver 8 fixed for me ;)

@hmagdy
Copy link

hmagdy commented Jul 16, 2019

Still not fixed on my side

node -v
v10.15.0

back to

npm install firebase-functions@3.0.2

@kurtzmarc
Copy link

This appears to be working for me in firebase-tools@7.1.1

@hyzhak
Copy link

hyzhak commented Jul 29, 2019

got the same issue. @samtstern Is there any chance to see it fixed soon?

@bkendall
Copy link
Contributor

@hyzhak this should be fixed in the latest release of firebase-tools. If you're having issues still, can you open a new issue with the appropriate information so we can better track it? thanks.

@Dean-NC
Copy link

Dean-NC commented Aug 5, 2019

For those running WSL 1 (linux on Windows 10), using firebase tools 7.10 or 7.2.2 to fix this issue might still be a problem, due to something in 7.10 causing a problem for WSL users: #1458.

I run WSL 1 with firebase tools 7.0.2, node 10, and installing firebase-functions@3.0.2 fixed this problem for me.

@leblancmeneses
Copy link

leblancmeneses commented Aug 8, 2019

For me it was because firebase-tools was installed globally after upgrading to latest.

npm uninstall -g firebase-tools

then update your scripts to to use npx equivalent commands.

npx -p firebase-tools serve 

https://twitter.com/leblancmeneses/status/1159349938331029504

@VagnerGon
Copy link

Still with the same problemn, solved with firebase-functions@3.0.2

@JoaoSant0s
Copy link

JoaoSant0s commented Apr 9, 2020

Worked with me:

  • delete the folder "node_modules" inside the "functions" folder
  • npm install the "firebase-functions" more recent (actually 3.6.0)
  • uncomment the code inside the "functions/src/index.ts"
  • try close and open the command line

@Stas-Buzunko
Copy link

here is what worked for me yesterday

1. npm i firebase-functions@latest
2. npm i -g firebase-tools@latest
3. close and open the command line

@VagnerGon
Copy link

VagnerGon commented Jun 12, 2020

Fixed in 4.15.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.