IntelliJ调试器已连接到Firebase本地仿真器,但不会在断点处停止。

huangapple go评论51阅读模式
英文:

IntelliJ debugger is connected to Firebase local emulator but doesn't stop at breakpoints

问题

我已经在这个问题上断断续续地工作了好几天。阅读并关注了我能找到的关于这个主题的所有帖子,但仍然无法使其正常工作。

我正在尝试在IntelliJ IDE中本地调试Firebase函数。以下是启动命令的输出:

**firebase emulators:start --inspect-functions**

> bear@paw:~/dev/test-cloud-functions$ firebase emulators:start --inspect-functions 
> i  emulators: Starting emulators: functions, firestore
> ⚠  functions: You are running the Functions emulator in debug mode (port=9229). This means that functions will execute in sequence rather than in parallel.
> ⚠  functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth, database, hosting, pubsub, storage
> i  firestore: Firestore Emulator logging to firestore-debug.log
> ✔  firestore: Firestore Emulator UI websocket is running on 9150.
> i  ui: Emulator UI logging to ui-debug.log 
> i  functions: Watching "/home/bear/dev/test-cloud-functions/functions" for Cloud Functions...
> ✔  functions: Using node@16 from host.
> ✔  functions: Loaded functions definitions from source: .
>  Debugger listening on ws://127.0.0.1:9229/8aef43e5-94cb-4d79-b178-92db4ba380c9
>  For help, see: https://nodejs.org/en/docs/inspector
> i  functions: Watching "/home/bear/dev/test-cloud-functions/mod" for Cloud Functions...
> ✔  functions: Using node@16 from host.
> ✔  functions: Loaded functions definitions from source: processTransaction, testFunction.
> ✔  functions[europe-west1-processTransaction]: firestore function initialized.
> ✔  functions[europe-west1-testFunction]: http function initialized (http://127.0.0.1:5001/testproject/europe-west1/testFunction).
>  Starting inspector on 127.0.0.1:9229 failed: address already in use
>
>┌─────────────────────────────────────────────────────────────┐
>│ ✔  All emulators ready! It is now safe to connect your app. │
>│ i  View Emulator UI at http://127.0.0.1:4000/               │
>└─────────────────────────────────────────────────────────────┘
>
>┌───────────┬────────────────┬─────────────────────────────────┐
>│ Emulator  │ Host:Port      │ View in Emulator UI             │
>├───────────┼────────────────┼─────────────────────────────────┤
>│ Functions │ 127.0.0.1:5001 │ http://127.0.0.1:4000/functions │
>├───────────┼────────────────┼─────────────────────────────────┤
>│ Firestore │ 127.0.0.1:8080 │ http://127.0.0.1:4000/firestore │
>└───────────┴────────────────┴─────────────────────────────────┘
>  Emulator Hub running at 127.0.0.1:4400
>  Other reserved ports: 4500, 9150
>
>Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files.
> 
>  Debugger attached.
>  Checking ip address
>  Outbound IP address is: 124.120.192.159

调试器配置已附加到端口9229上的Chrome/Node,并且似乎正常工作。但是,当我设置断点并通过在浏览器中打开链接http://127.0.0.1:5001/test-project/europe-west1/testFunction来调用testFunction时,函数会运行并显示外部IP地址的输出,而不会在断点处停止。有没有特殊的方法来调用Firebase模拟器函数以激活调试器?我漏掉了什么?请帮忙。

英文:

I've been at this for days on and off. Read through and followed all threads on the subject i could find but still can't get this to work.

I'm trying to debug Firebase functions locally in IntelliJ IDE. Here's the output of start command.

**firebase emulators:start --inspect-functions**

> bear@paw:~/dev/test-cloud-functions$ firebase emulators:start --inspect-functions \
> i  emulators: Starting emulators: functions, firestore\
> ⚠  functions: You are running the Functions emulator in debug mode (port=9229). This means that functions will execute in sequence rather than in parallel.\
> ⚠  functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth, database, hosting, pubsub, storage\
> i  firestore: Firestore Emulator logging to firestore-debug.log\
> ✔  firestore: Firestore Emulator UI websocket is running on 9150.\
> i  ui: Emulator UI logging to ui-debug.log \
> i  functions: Watching "/home/bear/dev/test-cloud-functions/functions" for Cloud Functions...\
> ✔  functions: Using node@16 from host.\
> ✔  functions: Loaded functions definitions from source: .\
>  Debugger listening on ws://127.0.0.1:9229/8aef43e5-94cb-4d79-b178-92db4ba380c9
>  For help, see: https://nodejs.org/en/docs/inspector
> i  functions: Watching "/home/bear/dev/test-cloud-functions/mod" for Cloud Functions...
> ✔  functions: Using node@16 from host.\
> ✔  functions: Loaded functions definitions from source: processTransaction, testFunction.\
> ✔  functions[europe-west1-processTransaction]: firestore function initialized.\
> ✔  functions[europe-west1-testFunction]: http function initialized (http://127.0.0.1:5001/testproject/europe-west1/testFunction).\
>  Starting inspector on 127.0.0.1:9229 failed: address already in use
>
>┌─────────────────────────────────────────────────────────────┐
>│ ✔  All emulators ready! It is now safe to connect your app. │
>│ i  View Emulator UI at http://127.0.0.1:4000/               │
>└─────────────────────────────────────────────────────────────┘
>
>┌───────────┬────────────────┬─────────────────────────────────┐
>│ Emulator  │ Host:Port      │ View in Emulator UI             │
>├───────────┼────────────────┼─────────────────────────────────┤
>│ Functions │ 127.0.0.1:5001 │ http://127.0.0.1:4000/functions │
>├───────────┼────────────────┼─────────────────────────────────┤
>│ Firestore │ 127.0.0.1:8080 │ http://127.0.0.1:4000/firestore │
>└───────────┴────────────────┴─────────────────────────────────┘
>  Emulator Hub running at 127.0.0.1:4400\
>  Other reserved ports: 4500, 9150\
>
>Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files.\
> 
>  Debugger attached.\  
>  Checking ip address\
>  Outbound IP address is: 124.120.192.159\

> ✔  functions: Using node@16 from host.\
> ✔  functions: Loaded functions definitions from source: processTransaction, testFunction.\
>  Starting inspector on 127.0.0.1:9229 failed: address already in use\
> ✔  functions: Using node@16 from host.\
> ✔  functions: Loaded functions definitions from source: processTransaction, testFunction.\
>  Starting inspector on 127.0.0.1:9229 failed: address already in use\
>  Checking ip address\
>  Outbound IP address is: 124.120.192.159\
>  Debugger ending on ws://127.0.0.1:9229/8aef43e5-94cb-4d79-b178-92db4ba380c9\
>  For help, see: https://nodejs.org/en/docs/inspector\
>  Debugger attached.

The debugger configuration is set attached to Chrome/Node on port 9229 and appears to be working fine. However when i set breakpoints and call the testFunction by opening a browser to http://127.0.0.1:5001/test-project/europe-west1/testFunction the function runs and shows its output of external ip address without stopping at the breakpoints. Is there a special way to call the Firebase emulator function in order to envoke the debugger? What am i missing? Please help.

答案1

得分: 1

From https://medium.com/@david_shortman/build-and-debug-firebase-functions-in-vscode-73efb76166cf, Using Firebase Functions from a Webpage in Javascript section I can see that such functions have to be debugged in a different way; you likely have to use JavaScript Debug run configuration (see Debugging a Webpage with Chrome debugger at the bottom of the page). Didn't try it myself though. Can you check if you can debug your functions in Chrome Dev Tools, for example? if it works, then debugging with JavaScript Debug run configuration should work as well.

I'd also suggest asking a question at Firebase Google Group

英文:

From https://medium.com/@david_shortman/build-and-debug-firebase-functions-in-vscode-73efb76166cf, Using Firebase Functions from a Webpage in Javascript section I can see that such functions have to be debugged in a different way; you likely have to use JavaScript Debug run configuration (see Debugging a Webpage with Chrome debugger at the bottom of the page). Didn't try it myself though. Can you check if you can debug your functions in Chrome Dev Tools, for example? if it works, then debugging with JavaScript Debug run configuration should work as well

I'd also suggest asking a question at Firebase Google Group

huangapple
  • 本文由 发表于 2023年3月31日 15:49:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/75896073.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定