Giter Club home page Giter Club logo

Comments (3)

JoostK avatar JoostK commented on August 15, 2024 1

Nice find! 💯

The monkey patch is slightly off, in the sense that loadedPlugins is assigned after an await point. Consequently plugins may still load multiple times when there's multiple calls before the promise has resolved.

I'd suggest something like

let loadedPlugins: Promise<LoadedNxPlugin[]>;
let cleanup: () => void;

export async function getPlugins() {
  return loadedPlugins ??= getPluginsWorker();
}


async function getPluginsWorker() {
  const pluginsConfiguration = readNxJson().plugins ?? [];
  const [result, cleanupFn] = await loadNxPlugins(
    pluginsConfiguration,
    workspaceRoot
  );
  cleanup = cleanupFn;
  return result;
}

That still leaves a race condition w.r.t. cleanupPlugins, which ideally becomes async as well to be able to wait any pending loadNxPlugins (otherwise the cleanup function is set after cleanup has already been invoked). Additionally, cleanup should probably be cleared once invoked to avoid any potential for memory leaks.

from nx.

alantreadway avatar alantreadway commented on August 15, 2024

NOTE: I'm working on the assumption that we've done the right thing in our monkey-patch, if that isn't the case I'm happy to try and put together a more trivial reproduction than our monorepo.

from nx.

ctaepper avatar ctaepper commented on August 15, 2024

I can confirm this bug with upgrade from 17.3 to > 18. I can also confirm that the mentioned monkey patch solves the problem for us

from nx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.