Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revisit whether CLI should wipe the emulator export directory #3600

Closed
misha-reyzlin-hier opened this issue Jul 23, 2021 · 5 comments
Closed
Labels
emulator-suite polish Small feature requests

Comments

@misha-reyzlin-hier
Copy link

[REQUIRED] Environment info

firebase-tools:

└ firebase --version
9.16.0

Platform:
macOS

[REQUIRED] Test case

  • Not sure what I should put here.

[REQUIRED] Steps to reproduce

  • Start the emulators with auth and database imports
  • Shut down emulators with one ctrl+c

[REQUIRED] Expected behavior

Emulators shut down and data is exported.

[REQUIRED] Actual behavior

Emulators print an error and the WHOLE FOLDER IS DELETED.

I am also unable to see the logs as the logs are deleted together with the working directory.

i  emulators: Received SIGINT (Ctrl-C) for the first time. Starting a clean shutdown.
i  emulators: Please wait for a clean shutdown or send the SIGINT (Ctrl-C) signal again to stop right now.
i  Automatically exporting data using --export-on-exit "." please wait for the export to finish...
i  Found running emulator hub for project hierfoods-develop at http://localhost:4400
i  Exporting data to: /Users/misha/Source/hierfoods-quickfixes/functions
i  emulators: Received export request. Exporting data to /Users/misha/Source/hierfoods-quickfixes/functions.
⚠  emulators: Export failed: ENOENT: no such file or directory, link '/Users/misha/Source/hierfoods-quickfixes/functions/firebase-export-1627057765461MzTjpC' -> '/Users/misha/Source/hierfoods-quickfixes/functions'
⚠  Export request failed, see emulator logs for more information.
⚠  Automatic export to "." failed, going to exit now...
i  emulators: Shutting down emulators.
i  ui: Stopping Emulator UI
⚠  Emulator UI has exited upon receiving signal: SIGINT
i  functions: Stopping Functions Emulator
i  hosting: Stopping Hosting Emulator
i  database: Stopping Database Emulator
i  auth: Stopping Authentication Emulator
i  hub: Stopping emulator hub
i  logging: Stopping Logging Emulator
@misha-reyzlin-hier
Copy link
Author

The way the emulators were started is probably to blame:

In the working path, we used:

firebase emulators:start --import . --export-on-exit .

This produced the relevant export files:

firebase-export-metadata.json
database_export
auth_export

And has worked OK for us until now, however at least only the exported files would be deleted by this bug and not the whole working folder alongside other important files.

Still, loosing data on export is really bad. Also, perhaps the tool could verify that the path is not the same working directory if there is a risk of confusion at export time?

@Muritavo
Copy link
Contributor

Muritavo commented Feb 3, 2022

Almost lost a project today because of this.

Take a look at this PR, it proposes a basic fix for this cenario. #4127

@yuchenshi
Copy link
Member

My two cents: we should go with #4127 in the short term but find a way to do exports without wiping the target directory.

The wiping behavior was introduced in #3511 to solve an unrelated issue but maybe we can find a better solution. Ideas are welcomed!

@yuchenshi yuchenshi added emulator-suite polish Small feature requests labels Feb 8, 2022
@yuchenshi
Copy link
Member

Workaround was released (#4127), repurpose this issue to track potentially revisiting the deletion behavior

@yuchenshi yuchenshi changed the title Full directory deletion at emulators shutdown Revisit whether CLI should wipe the emulator export directory Feb 28, 2022
@yuchenshi
Copy link
Member

Consolidating the discussion to #3962.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
emulator-suite polish Small feature requests
Projects
None yet
Development

No branches or pull requests

3 participants