Emulator Doesn't See File Changes In Debug Mode
Environment details
- OS: MacOS 10.13.4
- Node.js version: v6.11.5
- npm version: 3.10.10
- @google-cloud/functions-emulator version: 1.0.0-beta.4
Steps to reproduce
- deploy function:
functions deploy helloGET - call function:
functions call helloGET --data='{"stuff":"things"}'(observe results) - make change to file
- call function:
functions call helloGET --data='{"stuff":"things"}'(observe modified results from step 3) - debug function:
functions debug helloGET - call function:
functions call helloGET --data='{"stuff":"things"}'(observe results) - make change to file
- call function:
functions call helloGET --data='{"stuff":"things"}'(observe UNmodified results) - re-deploy function:
functions deploy helloGET - call function:
functions call helloGET --data='{"stuff":"things"}'(observe results) - make change to file
- call function:
functions call helloGET --data='{"stuff":"things"}'(observe modified results from step 11) Note: at no time did I actually attach a debugger in the scenario above, but even when connecting a debugger I find the exact same results whether I set breakpoints or not.
I've tried searching all over and looked at the functions --help output as much as I can. I don't know if this is expected behavior, then I can't find it in the docs. If this has already been asked, I apologize but I couldn't find another issue with this same scenario.
Thanks!
See feature added in #62. And reason this is disabled when in debug mode? I'd kinda like both! :)
EDIT: I just grabbed the source and now I see why --watch is not supported with the debug command. Looks like when the worker restarts due to a file change the debug port on the worker is closed. While I'm sure there is a technical solution here, I now understand the complexity of this sort of implementation.
My workaround is to issue the following between code changes while debugging:
$ functions reset someExportedFunction && f debug someExportedFunction
It's fairly quick and I'm only left with reconnecting the debugger. Maybe this could be added to a HowTo or Known Issues section of the FAQ?