cloud-functions-emulator icon indicating copy to clipboard operation
cloud-functions-emulator copied to clipboard

Emulator Doesn't See File Changes In Debug Mode

Open knitterb opened this issue 7 years ago • 1 comments

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

  1. deploy function: functions deploy helloGET
  2. call function: functions call helloGET --data='{"stuff":"things"}' (observe results)
  3. make change to file
  4. call function: functions call helloGET --data='{"stuff":"things"}' (observe modified results from step 3)
  5. debug function: functions debug helloGET
  6. call function: functions call helloGET --data='{"stuff":"things"}' (observe results)
  7. make change to file
  8. call function: functions call helloGET --data='{"stuff":"things"}' (observe UNmodified results)
  9. re-deploy function: functions deploy helloGET
  10. call function: functions call helloGET --data='{"stuff":"things"}' (observe results)
  11. make change to file
  12. 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!

knitterb avatar Mar 08 '18 01:03 knitterb

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?

knitterb avatar Mar 12 '18 18:03 knitterb