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 · 31 comments · Fixed by #1482
Closed

TypeError: _onRequestWithOpts is not a function #1480

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

Comments

@joeponzio
Copy link

@joeponzio joeponzio commented Jul 9, 2019

[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

This comment has been minimized.

Copy link

@lcarbonaro 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

This comment has been minimized.

Copy link
Contributor

@merlinnot merlinnot commented Jul 9, 2019

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

@hendrikswan

This comment has been minimized.

Copy link

@hendrikswan hendrikswan commented Jul 9, 2019

I'm also running into this issue.

@mmillerscsu

This comment has been minimized.

Copy link

@mmillerscsu mmillerscsu commented Jul 9, 2019

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

This comment has been minimized.

Copy link
Member

@samtstern samtstern commented Jul 9, 2019

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

@mmillerscsu

This comment has been minimized.

Copy link

@mmillerscsu mmillerscsu commented Jul 9, 2019

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

@lcarbonaro

This comment has been minimized.

Copy link

@lcarbonaro 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

This comment has been minimized.

Copy link
Member

@samtstern samtstern commented Jul 9, 2019

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

@lcarbonaro

This comment has been minimized.

Copy link

@lcarbonaro lcarbonaro commented Jul 9, 2019

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

@samtstern

This comment has been minimized.

Copy link
Member

@samtstern samtstern commented Jul 9, 2019

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

@lcarbonaro

This comment has been minimized.

Copy link

@lcarbonaro 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

This comment has been minimized.

Copy link

@mmillerscsu mmillerscsu commented Jul 9, 2019

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

@lcarbonaro

This comment has been minimized.

Copy link

@lcarbonaro lcarbonaro commented Jul 9, 2019

@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

This comment has been minimized.

Copy link

@mmillerscsu mmillerscsu commented Jul 9, 2019

@lcarbonaro got it to work now thanks.

@jheredia

This comment has been minimized.

Copy link

@jheredia jheredia commented Jul 9, 2019

Thanks @samtstern for the workaround, that helped me.

@lefnire

This comment has been minimized.

Copy link

@lefnire 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

This comment has been minimized.

Copy link

@jheredia 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

This comment has been minimized.

Copy link

@lefnire lefnire commented Jul 9, 2019

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

@abhay994

This comment has been minimized.

Copy link

@abhay994 abhay994 commented Jul 11, 2019

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

@converge

This comment has been minimized.

Copy link

@converge converge commented Jul 12, 2019

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

@samtstern

This comment has been minimized.

Copy link
Member

@samtstern samtstern commented Jul 12, 2019

@DouglasGMoore

This comment has been minimized.

Copy link

@DouglasGMoore DouglasGMoore commented Jul 13, 2019

no it hasnt been fixed

@dcts

This comment has been minimized.

Copy link

@dcts 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

This comment has been minimized.

Copy link

@Myolisi Myolisi commented Jul 15, 2019

npm install firebase-functions@3.0.2 fixed it for me

@manh-gntvn

This comment has been minimized.

Copy link

@manh-gntvn manh-gntvn commented Jul 16, 2019

Use node ver 8 fixed for me ;)

@hmagdy

This comment has been minimized.

Copy link

@hmagdy 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

This comment has been minimized.

Copy link

@kurtzmarc kurtzmarc commented Jul 24, 2019

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

@hyzhak

This comment has been minimized.

Copy link

@hyzhak hyzhak commented Jul 29, 2019

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

@bkendall

This comment has been minimized.

Copy link
Contributor

@bkendall bkendall commented Jul 30, 2019

@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

This comment has been minimized.

Copy link

@Dean-NC 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

This comment has been minimized.

Copy link

@leblancmeneses 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.