Friday, 28 April 2017

Using async/await inside for-of loop, memory leak?

Im using await inside for of loop, but it seems that it is causing memory leak.

 let fullItems = [];
 for (let item of items) {
    let transformedItem = transformItem(item);

    let itemGroups = await itemService.getItemGroups(item.id);
    transformedItem.groups = itemGroups.map(transformItemGroup);

    fullItems.push(transformedItem);
  }

Is there something wrong with my loop, or is this issue with babel?

If i change my loop to traditional for loop, I have no issues with memory usage.

My versions:

  • babel-cli: 6.18.0
  • babel-core: 6.18.0
  • babel-preset-env: 1.4.0
  • Node: 6.9.3


via devha

No comments:

Post a Comment