Skip to content

emulators not starting properly when emulating hosting on a vite project #5561

Closed

Description

@tanjunior

[REQUIRED] Environment info

firebase-tools: 11.24.0

Platform: windows

[REQUIRED] Test case

create new vite react project
firebase init hosting
firebase init emulators
firebase emluators:start

[REQUIRED] Steps to reproduce

create new vite react project
firebase init hosting
firebase init emulators
firebase emluators:start

[REQUIRED] Expected behavior

image
image

[REQUIRED] Actual behavior

image
image

Activity

  1. google-oss-bot commented on Feb 27, 2023

    @google-oss-bot
    Collaborator

    This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.

  2. joehan commented on Feb 28, 2023

    @joehan
    Member

    Hey @tanjunior - Could you share the debug logs from this error (firebase emluators:start --debug)?

  3. added
    Needs: Author Feedback
    on Feb 28, 2023
  4. tanjunior commented on Feb 28, 2023

    @tanjunior
    Author

    Hey @joehan heres the log on a fresh project
    firebase.json

    {
      "firestore": {
        "rules": "firestore.rules",
        "indexes": "firestore.indexes.json"
      },
      "hosting": {
        "source": ".",
        "ignore": [
          "firebase.json",
          "**/.*",
          "**/node_modules/**"
        ],
        "frameworksBackend": {
          "region": "asia-east1"
        }
      },
      "emulators": {
        "firestore": {
          "port": 8080
        },
        "hosting": {
          "port": 5000
        },
        "ui": {
          "enabled": true
        },
        "singleProjectMode": true
      }
    }

    firebase-debug.log

    [debug] [2023-02-28T17:16:14.583Z] ----------------------------------------------------------------------
    [debug] [2023-02-28T17:16:14.585Z] Command:       E:\dev\nodejs\node.exe C:\Users\JUNIOR\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js emulators:start --debug
    [debug] [2023-02-28T17:16:14.586Z] CLI Version:   11.24.0
    [debug] [2023-02-28T17:16:14.586Z] Platform:      win32
    [debug] [2023-02-28T17:16:14.586Z] Node Version:  v16.17.0
    [debug] [2023-02-28T17:16:14.588Z] Time:          Wed Mar 01 2023 01:16:14 GMT+0800 (Singapore Standard Time)
    [debug] [2023-02-28T17:16:14.588Z] ----------------------------------------------------------------------
    [debug] 
    [debug] [2023-02-28T17:16:14.675Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
    [debug] [2023-02-28T17:16:14.677Z] > authorizing via signed-in user ([email protected])
    [debug] [2023-02-28T17:16:14.785Z] openjdk version "19.0.2" 2023-01-17
    
    [debug] [2023-02-28T17:16:14.787Z] OpenJDK Runtime Environment (build 19.0.2+7-44)
    OpenJDK 64-Bit Server VM (build 19.0.2+7-44, mixed mode, sharing)
    
    [debug] [2023-02-28T17:16:14.797Z] Parsed Java major version: 19
    [info] i  emulators: Starting emulators: firestore, hosting {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: firestore, hosting"}}
    [debug] [2023-02-28T17:16:14.818Z] [logging] Logging Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
    [debug] [2023-02-28T17:16:14.819Z] [firestore] Firestore Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
    [debug] [2023-02-28T17:16:14.821Z] [firestore.websocket] websocket server for firestore only supports listening on one address (127.0.0.1). Not listening on ::1
    [debug] [2023-02-28T17:16:14.821Z] [hosting] Hosting Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
    [debug] [2023-02-28T17:16:14.822Z] assigned listening specs for emulators {"user":{"hub":[{"address":"127.0.0.1","family":"IPv4","port":4400},{"address":"::1","family":"IPv6","port":4400}],"ui":[{"address":"127.0.0.1","family":"IPv4","port":4000},{"address":"::1","family":"IPv6","port":4000}],"logging":[{"address":"127.0.0.1","family":"IPv4","port":4500}],"firestore":[{"address":"127.0.0.1","family":"IPv4","port":8080}],"firestore.websocket":[{"address":"127.0.0.1","family":"IPv4","port":9150}],"hosting":[{"address":"127.0.0.1","family":"IPv4","port":5000}]},"metadata":{"message":"assigned listening specs for emulators"}}
    [debug] [2023-02-28T17:16:14.828Z] [hub] writing locator at C:\Users\JUNIOR\AppData\Local\Temp\hub-meetme-1002f.json
    [debug] [2023-02-28T17:16:14.844Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/meetme-1002f [none]
    [debug] [2023-02-28T17:16:15.163Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/meetme-1002f 200
    [debug] [2023-02-28T17:16:15.164Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/meetme-1002f {"projectId":"meetme-1002f","projectNumber":"457632898932","displayName":"meetme","name":"projects/meetme-1002f","resources":{"hostingSite":"meetme-1002f"},"state":"ACTIVE","etag":"1_c2f9d6b4-e706-4eff-a8fc-17868025e19f"}
    [debug] [2023-02-28T17:16:17.898Z] >>> [apiv2][query] GET https://firebasehosting.googleapis.com/v1beta1/projects/meetme-1002f/sites pageToken=&pageSize=10
    [debug] [2023-02-28T17:16:18.732Z] <<< [apiv2][status] GET https://firebasehosting.googleapis.com/v1beta1/projects/meetme-1002f/sites 200
    [debug] [2023-02-28T17:16:18.732Z] <<< [apiv2][body] GET https://firebasehosting.googleapis.com/v1beta1/projects/meetme-1002f/sites {"sites":[{"name":"projects/meetme-1002f/sites/g11meetme","defaultUrl":"https://g11meetme.web.app","appId":"1:457632898932:web:5be7a4d5a4d737b6589621","type":"USER_SITE"},{"name":"projects/meetme-1002f/sites/meetme-1002f","defaultUrl":"https://meetme-1002f.web.app","type":"DEFAULT_SITE"}]}
    [debug] [2023-02-28T17:16:18.736Z] >>> [apiv2][query] GET https://firebasehosting.googleapis.com/v1beta1/projects/meetme-1002f/sites 
    [debug] [2023-02-28T17:16:19.531Z] <<< [apiv2][status] GET https://firebasehosting.googleapis.com/v1beta1/projects/meetme-1002f/sites 200
    [debug] [2023-02-28T17:16:19.532Z] <<< [apiv2][body] GET https://firebasehosting.googleapis.com/v1beta1/projects/meetme-1002f/sites {"sites":[{"name":"projects/meetme-1002f/sites/g11meetme","defaultUrl":"https://g11meetme.web.app","appId":"1:457632898932:web:5be7a4d5a4d737b6589621","type":"USER_SITE"},{"name":"projects/meetme-1002f/sites/meetme-1002f","defaultUrl":"https://meetme-1002f.web.app","type":"DEFAULT_SITE"}]}
    [debug] [2023-02-28T17:16:19.537Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/meetme-1002f/webApps/-/config [none]
    [debug] [2023-02-28T17:16:20.462Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/meetme-1002f/webApps/-/config 200
    [debug] [2023-02-28T17:16:20.462Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/meetme-1002f/webApps/-/config {"projectId":"meetme-1002f","appId":"1:457632898932:web:5be7a4d5a4d737b6589621","storageBucket":"meetme-1002f.appspot.com","apiKey":"AIzaSyC4_0kBuZLgDcHVlpHbiYm1zzTPq7sOjVk","authDomain":"meetme-1002f.firebaseapp.com","messagingSenderId":"457632898932"}
    [debug] [2023-02-28T17:16:33.035Z] Received signal SIGINT (Ctrl-C) 1
    
  5. added and removed
    Needs: Author Feedback
    on Feb 28, 2023
  6. christhompsongoogle commented on Mar 27, 2023

    @christhompsongoogle
    Contributor

    Question: did you send the SIGINT yourself or did that come from somewhere else? It looks like the startup didn't complete, since we didn't see a table with host:ports for the various emulators

  7. added
    Needs: Author Feedback
    and removed on Mar 28, 2023
  8. laurentpayot commented on Mar 28, 2023

    @laurentpayot

    @tanjunior In my Vite project I’m running my vite command as an argument of the firebase emulators:exec command:

    firebase emulators:exec --project demo-myproject 'vite' --ui
    

    Did you try this?

  9. tanjunior commented on Mar 28, 2023

    @tanjunior
    Author

    Question: did you send the SIGINT yourself or did that come from somewhere else? It looks like the startup didn't complete, since we didn't see a table with host:ports for the various emulators

    Yes I did ctrl+c myself. Yes the table with host:ports doesn't shows up as shown in the screen shot below.

    [REQUIRED] Actual behavior

    image

  10. added and removed
    Needs: Author Feedback
    on Mar 28, 2023
  11. tanjunior commented on Mar 28, 2023

    @tanjunior
    Author

    @tanjunior In my Vite project I’m running my vite command as an argument of the firebase emulators:exec command:

    firebase emulators:exec --project demo-myproject 'vite' --ui
    

    Did you try this?

    I didn't know this argument existed. I will give it a try.

  12. tanjunior commented on Apr 3, 2023

    @tanjunior
    Author

    @tanjunior In my Vite project I’m running my vite command as an argument of the firebase emulators:exec command:

    firebase emulators:exec --project demo-myproject 'vite' --ui
    

    Did you try this?

    i  Running script: vite
    'vite' is not recognized as an internal or external command,
    operable program or batch file.
    !  Script exited unsuccessfully (code 1)
    i  emulators: Shutting down emulators.
    
  13. jamesdaniels commented on Apr 12, 2023

    @jamesdaniels
    Contributor

    Since you're using hosting.source in your firebase.json, "vite" should be implied when spinning up the emulators. Can you try firebase emulators:start --project demo-myproject? We've had a couple fixes in the latest CLI too, might be worth updating.

  14. baraya commented on Apr 19, 2023

    @baraya

    @jamesdaniels @tanjunior

    Had the same issue. The promise from the below function does not get resolved because match does not return with the ip.. which is caused from the port having ansii bold characters.

    The screen output from vite is pretty, but if you JSON.stringify(data.toString()), you get

    "  \u001b[32m➜\u001b[39m  \u001b[1mLocal\u001b[22m:   \u001b[36mhttp://127.0.0.1:\u001b[1m5173\u001b[22m/\u001b[39m\n\u001b[2m  \u001b[32m➜\u001b[39m  \u001b[1mNetwork\u001b[22m\u001b[2m: use \u001b[0m\u001b[1m--host\u001b[22m\u001b[2m\u001b[0m to expose\u001b[22m\n"
    

    export async function getDevModeHandle(dir: string) {

    How I fixed it
    baraya@5ca45eb

    Now the function completes and the other emulators continue to start.

  15. Kaev commented on Apr 29, 2023

    @Kaev

    I'm encountering this problem aswell.

  16. laurentpayot commented on May 1, 2023

    @laurentpayot
    i  Running script: vite
    'vite' is not recognized as an internal or external command,
    operable program or batch file.
    !  Script exited unsuccessfully (code 1)
    i  emulators: Shutting down emulators.
    

    Does the vite command at least work?

  17. tanjunior commented on May 1, 2023

    @tanjunior
    Author
    i  Running script: vite
    'vite' is not recognized as an internal or external command,
    operable program or batch file.
    !  Script exited unsuccessfully (code 1)
    i  emulators: Shutting down emulators.
    

    Does the vite command at least work?

    yes.

    @tanjunior In my Vite project I’m running my vite command as an argument of the firebase emulators:exec command:

    firebase emulators:exec --project demo-myproject 'vite' --ui
    

    Did you try this?

    I tested this again and it seems like the error comes from enclosing vite in quotes. firebase emulators:exec --project demo-myproject vite --ui works at launching emulators suite with hosting. Though it still does not prints out the table showing the ports.

    What I found the most compatible for vite and firebase for now is to change the hosting config to

      "hosting": {
        "public": "dist",
        "rewrites": [
          {
            "source": "**",
            "destination": "/index.html"
          }
        ],
        "ignore": [
          "firebase.json",
          "**/.*",
          "**/node_modules/**"
        ],
        "frameworksBackend": {
          "region": "asia-east1"
        },
        "predeploy": [
          "npm run build"
        ]
      },
    

    and simply run firebase emulators:start

    This config will also help when using firebase deploy related to another issue I found #5564

  18. akashlama1998-icloud commented on Jul 25, 2023

    @akashlama1998-icloud

    I think the problem is in vite. When firebase hosting emulator runs the development script for vite it runs vite dev. Now, the problem is when we run vite dev, the console looks something like.

    $ vite dev
    
      VITE v4.4.7  ready in 3109 ms
    
      ➜  Local:   http://localhost:5173/
      ➜  Network: http://172.24.80.1:5173/
      ➜  Network: http://192.168.43.173:5173/
      ➜  press h to show help

    As you can see in the console, the command vite dev is waiting for an input, a key press if you will. And I think this is what that is not letting the firebase emulator start command to do it's thing further.

  19. added a commit that references this issue on Dec 14, 2023
  20. added a commit that references this issue on Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions