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

Async Migrations #123

Open
Nokel81 opened this issue Aug 11, 2020 · 6 comments
Open

Async Migrations #123

Nokel81 opened this issue Aug 11, 2020 · 6 comments

Comments

@Nokel81
Copy link

Nokel81 commented Aug 11, 2020

Given that many other libraries are moving to providing async only APIs the fact that migrations cannot be (reliably) an async function (IMO) is detrimental since moving from sync -> async is a non-breaking change for the migrations type but there is no (sane) way to guarantee an async migration is run to completion before the rest of the application starts doing its work.

@sindresorhus
Copy link
Owner

What kind of migrations are you doing that requires it to be async?

@Nokel81
Copy link
Author

Nokel81 commented Aug 11, 2020

Specifically I want to use this library https://github.com/sindresorhus/file-type (which I literally just realized is also by you, thanks!!)

@Nokel81
Copy link
Author

Nokel81 commented Aug 11, 2020

Namely, the conversion from a path to storing something within the store (along with its MIME type)

@sindresorhus
Copy link
Owner

There's, unfortunately, no way to make the migration be async without making every single conf method async too, which won't happen in the near term, if ever.

That being said, I made this for you: https://github.com/sindresorhus/make-synchronous

@Nokel81
Copy link
Author

Nokel81 commented Aug 18, 2020

Thank you for the new package. I can completely understand the magnitude of converting conf to async.

@fregante
Copy link
Contributor

fregante commented Aug 18, 2020

there is no (sane) way to guarantee an async migration is run to completion before the rest of the application starts doing its work

In a similar package to this, but for web extensions, make every get/set call await the migration promise. At least 80% sane IMHO?

In your case you could do the same, await the migrations before the app is "ready". A lot of apps do that, for example Apple Photos (Mac) and LINE Messages (iOS)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants