-
Notifications
You must be signed in to change notification settings - Fork 1k
Firebase Functions Shell Debugging #517
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
Comments
So, my original thoughts were wrong.. I can see firebase-tools calling .deploy(name, opts) and I'm guessing it's around there that the .debug() should be called. But I'm unable to pass the type parameter, or find any documentation on the debug api for cloud functions. It seems much more complex than I initially though, interested to hear if anyone has any ideas. Happy to close issue if inappropriate. |
Node debugging is a bit tricky. The Cloud Functions emulator creates child processes to properly emulate the isolation of production. We have a handful of bugs to tackle to configure debuggers to follow the forked processes. Eventually this will work without any hackery on your part. |
Has there been any changes to the debugging process for firebase functions? |
Not yet unfortunately. We've been scrambling on a number of other things. |
@ahaverty were you successful debugging the shell? I have a fairly complex function that runs fine when everything is mocked but fails hard when executing in emulator. |
Any success?, trying to debug firebase functions in vs code here too. |
@Seikilos @nschurmann nothing here, no 😔 |
Is there any way at all to debug firebase functions with a debugger? Any option I've tried hasn't worked. Specifically trying to debug onWrite functions. |
Hey everyone, I know it's probably been a bit disappointing to have us be so silent on this thread. Unfortunately IDE debugger integration isn't staffed right now, so we'll need some community help if you want |
@inlined how soon? 😄 |
I believe he was referring to our slate of new releases today including the brand-new firebase-functions-test library that should help you test your functions! |
VScode just released node debug process attaching. https://code.visualstudio.com/updates/v1_22#_node-debugging I'll give it a shot next week or if any of the firebase team have some undocumented/unofficial guides 😉 |
Just tried out "live" RTDB unit testing on functions v1.0.1 + mocha (followed the guides here), https://firebase.google.com/docs/functions/unit-testing |
@ahaverty care to share? I'm trying to do the following:
|
If I understand @ahaverty 's comment correctly, they're referring to mocha tests, which are much simpler to debug. Mocha runs everything in a single process, whereas the Cloud Functions emulator actually emulates the process isolation you get in GCF. The |
I know this has been up for some time, is there any progress with VSCode or |
@alexsorokoletov I use the Cloud Functions Emulator for this and it works fine for me with Firebase functions, it gives you a command-line tool that you can attach to a function in VSCode. |
It looks like firebase-functions-test and the ability to attach to the Cloud Functions Emulator have solved the particular issue raised in this thread. Closing this out. |
If anyone's interested, I figured out a small hack to make this work: master...jsherwani:support-debug FYI, you can add the above changes (just one function call) manually into |
Actually, here's a much simpler way:
|
@jsherwani It does not work for me:
|
@dvdmmc Can you share the details about how you made that work? |
@bageren For the most part, the online documentation should help you get set up. Let me know if you have any particular error messages and I can help you.
I haven't looked at this in a while so perhaps there is a better way of making Authorized requests now, but it's still working for me so I haven't looked at it too closely. To debug, make sure you're deploying the emulator functions using something like: Hope this helps. |
|
I think it's time to reopen this as https://github.com/googlearchive/cloud-functions-emulator has been deprecated. I tried doing what @jimmont said but I got
So setting GCLOUD_PROJECT wouldn't be enough - and also, I can't find information on what these variables should be. |
@marcospgp we are working on breakpoint debugging in the newer emulator (see #1798) and others. |
@marcospgp I was able to set the GCLOUD_PROJECT variable by itself (as @jimmont wrote above) and everything worked as expected. There was a message indicating that FIREBASE_CONFIG was missing but would be inferred by the value of GCLOUD_PROJECT. As long as you are using a standard Firebase setup (standard database url) everything should work. |
* starts on extension emualtor commands * further work on ext emulator * Progress on emulator * more logs * Successfully emualted firestore counter! with some crednetial problems * cleans up consoel.logs * sets env during laod triggers * format * removes uneeded file changes * removes uneeded file changes * add ext:dev:emulators:exec * formats * DRYing up exec * reorganizing code and making initial fixes suggested by Sam * more fixes * added ext:emualtor flags * adds directory climbing to find an extension.yaml file * adds unit tests for triggerHelper * adds unit tests for paramHelper * typo * adds unit tests for paramHelper * adds unit tests for paramHelper * pr fixes * typo and unused import * pr fixes * add sourceDirectory detection * formats * pr fixes * moving some flags around; * default sourcedirectory to functions * adds param validation * style fix * adds tests for param validation * adds regex validation and tests * emulator-> emulators * pr fixes; * adds log for missing trigger * formatted * removes unneeded import of _ * slightly better error message * Add "firebase ext:dev:init" command (#506) * formatting; * fixing package-lock * pass predefined triggers to FunctionEmulatorRuntime so they are always available at runtime * remove commented out code; * removes newline * format/ * predefinedTriggers->extensiontriggers * use project provided by --project flag * remove source directory line (#510) * Update WELCOME.md for ext:dev:init (#509) * adds validation for multiselect and select params * typo fix * also reject empty string for reqd params * moves validation utils to extensionHelper, adds validateSpec, adds unit tests * copy fixes, and adds an extra check for param type * pr fixes and extra tests * remove hardcoded variable; * remove hardcoded variable; * remove hardcoded variables * bug fix and remove console log * add runtime field to ext spec (#514) * add runtime field to ext spec * use getProjectId instead of options.project * typo fix in test description * differentiate javascript/typescript welcome messages (#513) * differentiate javascript/typescript welcome messages * adds support for --test-config * Update src/extensions/emulator/optionsHelper.ts Co-Authored-By: rachelsaunders <[email protected]> * Update src/extensions/emulator/optionsHelper.ts Co-Authored-By: rachelsaunders <[email protected]> * Update src/extensions/emulator/optionsHelper.ts Co-Authored-By: rachelsaunders <[email protected]> * Update src/extensions/emulator/optionsHelper.ts Co-Authored-By: rachelsaunders <[email protected]> * use JSON.parse instead; * finalizing copy * Update src/extensions/emulator/optionsHelper.ts Co-Authored-By: rachelsaunders <[email protected]> * Update src/extensions/emulator/optionsHelper.ts Co-Authored-By: rachelsaunders <[email protected]> * Update src/extensions/emulator/optionsHelper.ts Co-Authored-By: rachelsaunders <[email protected]> * Validate all params instead of stopping on a failed param (#518) * check all params instead of stopping on a failed param * copy fix * Update src/test/extensions/askUserForParam.spec.ts Co-Authored-By: rachelsaunders <[email protected]> * Update src/extensions/askUserForParam.ts Co-Authored-By: rachelsaunders <[email protected]> * Update src/test/extensions/askUserForParam.spec.ts Co-Authored-By: rachelsaunders <[email protected]> Co-authored-by: rachelsaunders <[email protected]> * adds validation that default value passes validationRegex (#517) * Add extdev preview and hide ext:dev commands behind it (#519) * add extdev preview and hide ext:dev commands behind it * formats; * add ext to previews * formats * formats * formats * hide local functionality from non preview users * more accurate error messages * formats * missing space Co-authored-by: Lauren Long <[email protected]> Co-authored-by: Tina Liang <[email protected]> Co-authored-by: rachelsaunders <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
Version info
I'm looking to locally debug my emulated functions (in vscode for now) using the new
experimental:functions:shell
.In firebase/firebase-functions#4 @laurenzlong mentions it should be capable with firebase shell, if it's possible in google cloud functions emulator.
(I'm going with a github issue over an SO post or support ticket, as this may lead to a nice PR if the firebase team aren't already working on this feature.)
I've yet to get anything to attach, and i'm not too familiar with attaching to debug processes. Here's what I've tried, working backwards from the google cloud functions instructions:
Launch command for firebase emulator:
firebase experimental:functions:shell --port 5000
//forcing port 5000 to simplify the launch task, we could possibly look into connecting to the process directly if this is smelly
My launch.json in vscode:
In the firebase tools emulator script, it looks like we're only calling start() for each function. Whereas, according to the debugging google cloud functions guide, we need to be calling
debug() in order to allow attaching the debugger.
I'm assuming the firebase functions emulator will have some options in the future, something like
--debug
. If anyone has any tips/pointers that might help me investigate, please let me know 👌I'm going to attempt:
Modifying the script to attach to my node debugger.
Adding
--debug
flag if I can get that to work, and possibly PR if firebase is happyThe text was updated successfully, but these errors were encountered: