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

Eliminate Bluebird in favor of native async functionality #3662

Closed
4 tasks
AbhishekReddy1127 opened this issue Mar 22, 2023 · 5 comments · Fixed by #4026
Closed
4 tasks

Eliminate Bluebird in favor of native async functionality #3662

AbhishekReddy1127 opened this issue Mar 22, 2023 · 5 comments · Fixed by #4026
Assignees
Labels
dependencies Pull requests that update a dependency file good first issue Good for newcomers help wanted Community development is encouraged technical debt If not paid, jeapardizes long-term success and maintainability of the repository.

Comments

@AbhishekReddy1127
Copy link
Contributor

AbhishekReddy1127 commented Mar 22, 2023

Bluebird is a open-source JavaScript library for working with asynchronous code. It is a Promise library that provides a number of useful features and enhancements to the built-in JavaScript Promise object, including performance optimizations and additional methods.

The task is to replace all instances of Bluebird with native async functionality in the codebase. This should be done using the async and await keywords, which have been natively available for over 5 years in all relevant environments. Promises have also been available for longer.

  • Identify all instances where Bluebird is used in the codebase
  • Replace the Bluebird calls with the equivalent native async functionality using async and await
    • Below are the list of bluebird functions that are currently used and their equivalent native implementation
         all -> Promise.all
         settle -> Promise.allSettled
         resolve -> Promise.resolve
         reject-> Promise.reject
         setSchedular -> queueMicrotask
         fromNode ->  const util = require('util');
                                await util.promisify(readFileCallback);
         delay ->  function delay(ms) {
                        return new Promise(resolve => setTimeout(resolve, ms));}
         mapAsync -> function mapAsync(array, mapper) {
                               return Promise.all(array.map(mapper));}
         promisify -> await util.promisify(fs.readFile);
  • Test the updated code to ensure that it is functioning as expected
@joshuarrrr joshuarrrr added help wanted Community development is encouraged dependencies Pull requests that update a dependency file technical debt If not paid, jeapardizes long-term success and maintainability of the repository. and removed untriaged labels Mar 22, 2023
@Nicksqain
Copy link
Contributor

@AbhishekReddy1127
I want to resolve this issue. Can I find out which directory to update to native code?

@ashwin-pc ashwin-pc added the good first issue Good for newcomers label Apr 8, 2023
@abbyhu2000
Copy link
Member

abbyhu2000 commented Apr 11, 2023

Hi @Nicksqain, thank you for your interest in solving this issue! We have broken this issue into three steps, while the first step is to identify all instances where Bluebird is used in the codebase, here are some tips that can get you started:

  1. When I search 'bluebird' in our repository, i see there are 70 results in 30 files.
    Screenshot 2023-04-11 at 10 31 43 AM

For example, i see some usages in src/dev directory, some usages in packages/osd-opensearch-archiver, some usages in the plugins, especially vis_type_timeline plugin (src/plugins/vis_type_timeline) as well as saved object plugin (src/plugins/saved_object) and vis_type_tagcloud plugin (src/plugins/vis_type_tagcloud), and also in the functional tests test/functional

  1. Go down the file list and go through each instance of the Bluebird usage. Here is their API references. However, you might also be able to find some patterns. For example, the functional tests only uses two functions delay and map from Bluebird.
  2. Explore how to use native implementations to replace these bluebird functions. Since it involves 30 files and multiple directories, you can probably submit multiple PRs so that each PR just target one directory. For example, one PR that replaces all the bluebird functions in the functional tests test/functional; one PR for all the plugins src/plugins; one PR for src/dev, one PR for packages/osd-opensearch-archiver and any other files.

@Nicksqain
Copy link
Contributor

@abbyhu2000 Thanks for the answer! For example, I will create an analogue of some method, where can I save this function? Or copy it every time?

@Nicksqain
Copy link
Contributor

@abbyhu2000 I don't do PRs the way you described, I made a different PR for each plugin.

Could you please complete the description of the issue?
Make "checkpoints" for each task - my PRs so you can track progress.
e.g - [x] Add bluebird replaces for test/functional

and in which PR should I add changelod.md entry?

@Nicksqain
Copy link
Contributor

@ananzh Is this issue closed?

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