flamelink / gatsby-source-flamelink

Gatsby source plugin for Flamelink
MIT License
8 stars 9 forks source link

Multiple language concurrency issue #23

Closed leevi978 closed 4 years ago

leevi978 commented 4 years ago

Hello! I am currently using gatsby-source-flamelink v:2.1.2, and I have come over a bug in gatsby-node.js.

After pulling your source code and console logging while running it with my project, it seems to me that this is a problem with concurrency and the way async functions are being executed. There is a mapping function that maps over all the available locales provided.

... await Promise.all( availableLocales.map(async locale => { logInfo(Start processing locale: ${locale}) await api.setLocale(locale)

    if (content) {

...

It seems to me that the intention of this mapping is to iterate over each locale, set the api locale to the given locale, and then pull all the nodes with that given locale.

However, when I console log the process, this mapping will first iterate through every locale and set the api locale to the given locale. Next, it will iterate again over each locale and pull data. As a result, the nodes created are duplicates of the last locale specified.

More specifically, when I specify locales: ['no', 'en-US'] in the gatsby-config file, the following will happen:

jperasmus commented 4 years ago

Thanks for opening the issue, Levi. I will take a look and get back to you. 👍

jperasmus commented 4 years ago

Hi, do you mind testing this with the latest alpha version: 3.0.0-alpha.3. You can install it with npm install gatsby-source-flamelink@next

leevi978 commented 4 years ago

I just tested the alpha version with my project, and it seems to be working fine now, at least with the two languages I am using. When I look at my graphql nodes, they are showing the correct content in both languages. Thank you for fixing it!

jperasmus commented 4 years ago

Excellent! I'm glad to hear that. I would recommend you use this alpha version for new projects because it also has a few other fixes that are not in the v2 version.