Skip to content

Cannot read property 'deploys' of undefined #1232

Closed
@Reedyuk

Description

@Reedyuk

Environment info

firebase-tools:
firebase-tools@6.7.2

Platform:
MacOS

Test case

MacOS, Node 10.15.3, firebase-tools@6.7.2

Steps to reproduce

Create two hosting sites on firebase console.
Run
'firebase target:apply hosting dev firebase-hosting-id'
Run
'firebase deploy --only hosting:dev'

Expected behavior

Deployment successful

Actual behavior

[info] Project Console: https://console.firebase.google.com/project/project-name/overview
[debug] [2019-05-01T19:12:12.726Z] TypeError: Cannot read property 'deploys' of undefined
    at /Users/reeda/.nvm/versions/node/v10.15.3/lib/node_modules/firebase-tools/lib/deploy/index.js:88:36
    at process._tickCallback (internal/process/next_tick.js:68:7)
[error] 
[error] Error: An unexpected error has occurred.

Activity

bkendall

bkendall commented on May 1, 2019

@bkendall
Contributor

There's been some adjustments in this flow recently. This error is coming from (in the source): https://github.com/firebase/firebase-tools/blob/master/src/deploy/index.js#L111

@Memeriaj can you take a look as you've been dealing with this lately?

Memeriaj

Memeriaj commented on May 2, 2019

@Memeriaj
Contributor

I think I may know what is going on here. Does your firebase.json config file have "target": "dev" in it? I believe that we filtered out all of the configs that didn't match hosintg:dev and we were left with an empty array. We then went through all of the deploy steps for that empty array, effectively doing nothing. Then at the end we display the console link and the link to your newly deployed Hosting Site, which is where this error pops up because we didn't actually deploy anything.

We definitely need a proper error in this case explaining that we're not deploying anything.

(unrelated to the issue: generally you want to have your environment level switching be on a Firebase project level basis and not on different Hosting Sites within the same project (though you might have a Site for a blog, a Site for a web app, and a Site for your Docs that are all in the same environment on different Hosting Sites on the same project). This is mainly because things like Firebase Auth have only a single instance within a project. Ideally your firebase.json file is set up in such a way that you'd be able to something like firebase use dev, firebase deploy, check dev to make sure things are working, firebase use staging, firebase deploy, ...)

Reedyuk

Reedyuk commented on May 3, 2019

@Reedyuk
Author

{ "firestore": { "rules": "firestore.rules", "indexes": "firestore.indexes.json" }, "hosting": { "public": "build", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ], "rewrites": [ { "source": "**", "destination": "/index.html" } ] }, "functions": { "predeploy": [ "npm --prefix \"$RESOURCE_DIR\" run lint" ] } }

Reedyuk

Reedyuk commented on May 3, 2019

@Reedyuk
Author

I think the config you mention is in the firebase bashrc file and not the firebase json file.

Memeriaj

Memeriaj commented on May 3, 2019

@Memeriaj
Contributor

Under the hosting section of the firebase.json file you need to have "target": "dev" in order for firebase deploy --only hosting:dev to work. The --only flag works like a filter and without the target field in your Hosting configuration then the CLI is not deploying anything (which should be an error with a useful message, but right now just blindly accepts it).

Reedyuk

Reedyuk commented on May 3, 2019

@Reedyuk
Author

Sorry, its not clear where in the json to put the target field, would i put this at the root of the json(it didnt work) or should it be in the root of the hosting(also didnt work for me).

Reedyuk

Reedyuk commented on May 3, 2019

@Reedyuk
Author

Also my firebaserc file, references my root project but it doesnt have any reference to the my second hosting site, so im not sure how the CLI tool will be able to understand where to deploy to.

43 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @mbleigh@bkendall@killroy42@Memeriaj@hequ

      Issue actions

        Cannot read property 'deploys' of undefined · Issue #1232 · firebase/firebase-tools