@depup/nx 23.1.2-depup.1 → 23.2.0-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/changes.json +12 -8
- package/dist/bin/init-local.js +3 -5
- package/dist/bin/nx.js +1 -0
- package/dist/src/adapter/ngcli-adapter.js +60 -1
- package/dist/src/ai/constants.d.ts +15 -0
- package/dist/src/ai/constants.js +17 -1
- package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +57 -9
- package/dist/src/ai/utils.d.ts +13 -0
- package/dist/src/ai/utils.js +29 -0
- package/dist/src/analytics/analytics.js +2 -4
- package/dist/src/command-line/completion/command-object.js +7 -12
- package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +42 -31
- package/dist/src/command-line/format/format.js +84 -101
- package/dist/src/command-line/generate/generate.js +35 -35
- package/dist/src/command-line/import/import.js +29 -38
- package/dist/src/command-line/init/ai-agent-prompts.js +5 -11
- package/dist/src/command-line/init/command-object.js +4 -2
- package/dist/src/command-line/init/configure-plugins.js +4 -1
- package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +12 -32
- package/dist/src/command-line/init/implementation/add-nx-to-nest.js +17 -21
- package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +8 -21
- package/dist/src/command-line/init/implementation/add-nx-to-turborepo.js +3 -17
- package/dist/src/command-line/init/implementation/angular/index.js +10 -15
- package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +2 -0
- package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +8 -2
- package/dist/src/command-line/init/implementation/check-compatible-with-plugins.js +2 -0
- package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +5 -0
- package/dist/src/command-line/init/implementation/format.d.ts +18 -0
- package/dist/src/command-line/init/implementation/format.js +114 -0
- package/dist/src/command-line/init/implementation/utils.js +8 -8
- package/dist/src/command-line/init/init-v1.js +15 -18
- package/dist/src/command-line/init/init-v2.js +77 -66
- package/dist/src/command-line/migrate/agentic/definitions.js +36 -9
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +37 -22
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +30 -39
- package/dist/src/command-line/migrate/agentic/handoff.d.ts +7 -7
- package/dist/src/command-line/migrate/agentic/handoff.js +13 -10
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +7 -12
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +7 -0
- package/dist/src/command-line/migrate/agentic/run-step.d.ts +10 -0
- package/dist/src/command-line/migrate/agentic/run-step.js +1 -0
- package/dist/src/command-line/migrate/agentic/runner.js +24 -24
- package/dist/src/command-line/migrate/agentic/select.d.ts +10 -2
- package/dist/src/command-line/migrate/agentic/select.js +30 -32
- package/dist/src/command-line/migrate/agentic/types.d.ts +33 -3
- package/dist/src/command-line/migrate/agentic/types.js +35 -0
- package/dist/src/command-line/migrate/command-object.d.ts +6 -0
- package/dist/src/command-line/migrate/command-object.js +19 -1
- package/dist/src/command-line/migrate/execute-migration.d.ts +28 -9
- package/dist/src/command-line/migrate/execute-migration.js +112 -27
- package/dist/src/command-line/migrate/migrate-analytics.d.ts +35 -0
- package/dist/src/command-line/migrate/migrate-analytics.js +64 -0
- package/dist/src/command-line/migrate/migrate-commits.d.ts +38 -8
- package/dist/src/command-line/migrate/migrate-commits.js +130 -15
- package/dist/src/command-line/migrate/migrate-config.d.ts +13 -12
- package/dist/src/command-line/migrate/migrate-config.js +22 -14
- package/dist/src/command-line/migrate/migrate-output.d.ts +45 -7
- package/dist/src/command-line/migrate/migrate-output.js +52 -8
- package/dist/src/command-line/migrate/migrate-ui-api.d.ts +2 -1
- package/dist/src/command-line/migrate/migrate-ui-api.js +16 -7
- package/dist/src/command-line/migrate/migrate.d.ts +24 -55
- package/dist/src/command-line/migrate/migrate.js +553 -226
- package/dist/src/command-line/migrate/migration-shape.d.ts +8 -0
- package/dist/src/command-line/migrate/multi-major.js +7 -10
- package/dist/src/command-line/migrate/resolve-package-version.js +4 -8
- package/dist/src/command-line/migrate/run/agent-output.d.ts +20 -0
- package/dist/src/command-line/migrate/run/agent-output.js +65 -0
- package/dist/src/command-line/migrate/run/index.d.ts +9 -0
- package/dist/src/command-line/migrate/run/index.js +23 -0
- package/dist/src/command-line/migrate/run/orchestrator.d.ts +20 -0
- package/dist/src/command-line/migrate/run/orchestrator.js +1200 -0
- package/dist/src/command-line/migrate/run/run-id.d.ts +16 -0
- package/dist/src/command-line/migrate/run/run-id.js +56 -0
- package/dist/src/command-line/migrate/run/run-state.d.ts +157 -0
- package/dist/src/command-line/migrate/run/run-state.js +438 -0
- package/dist/src/command-line/migrate/run/state-lock.d.ts +25 -0
- package/dist/src/command-line/migrate/run/state-lock.js +76 -0
- package/dist/src/command-line/migrate/run/state-machine.d.ts +84 -0
- package/dist/src/command-line/migrate/run/state-machine.js +315 -0
- package/dist/src/command-line/migrate/run/util.d.ts +59 -0
- package/dist/src/command-line/migrate/run/util.js +148 -0
- package/dist/src/command-line/migrate/run/worker.d.ts +16 -0
- package/dist/src/command-line/migrate/run/worker.js +682 -0
- package/dist/src/command-line/migrate/run-migration-process.js +6 -5
- package/dist/src/command-line/migrate/safe-prompt.d.ts +14 -26
- package/dist/src/command-line/migrate/safe-prompt.js +32 -43
- package/dist/src/command-line/migrate/sort-migrations.d.ts +16 -0
- package/dist/src/command-line/migrate/sort-migrations.js +32 -0
- package/dist/src/command-line/migrate/step-actions.d.ts +5 -0
- package/dist/src/command-line/migrate/step-actions.js +12 -0
- package/dist/src/command-line/migrate/text.d.ts +18 -0
- package/dist/src/command-line/migrate/text.js +26 -0
- package/dist/src/command-line/migrate/version-skew-guard.d.ts +60 -0
- package/dist/src/command-line/migrate/version-skew-guard.js +175 -0
- package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +16 -20
- package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.d.ts +2 -0
- package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.js +16 -0
- package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.d.ts +4 -0
- package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.js +13 -0
- package/dist/src/command-line/nx-commands.js +26 -24
- package/dist/src/command-line/release/changelog.js +6 -17
- package/dist/src/command-line/release/plan.js +15 -28
- package/dist/src/command-line/release/publish.js +5 -0
- package/dist/src/command-line/release/release.js +6 -17
- package/dist/src/command-line/release/utils/release-graph.d.ts +1 -0
- package/dist/src/command-line/release/utils/release-graph.js +10 -2
- package/dist/src/command-line/release/utils/remote-release-clients/github.js +10 -22
- package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +13 -22
- package/dist/src/command-line/release/utils/resolve-semver-specifier.js +19 -41
- package/dist/src/command-line/release/version/resolve-current-version.js +7 -10
- package/dist/src/command-line/release/version.js +2 -2
- package/dist/src/command-line/reset/reset.js +17 -15
- package/dist/src/command-line/yargs-utils/shared-options.d.ts +1 -1
- package/dist/src/command-line/yargs-utils/shared-options.js +3 -1
- package/dist/src/config/misc-interfaces.d.ts +19 -7
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/core/graph/styles.js +1 -1
- package/dist/src/daemon/client/client.d.ts +2 -7
- package/dist/src/daemon/client/client.js +113 -28
- package/dist/src/daemon/client/daemon-environment.d.ts +35 -0
- package/dist/src/daemon/client/daemon-environment.js +106 -6
- package/dist/src/daemon/client/daemon-socket-messenger.d.ts +1 -1
- package/dist/src/daemon/client/daemon-socket-messenger.js +8 -3
- package/dist/src/daemon/is-v8-serializer-enabled.d.ts +2 -2
- package/dist/src/daemon/is-v8-serializer-enabled.js +2 -2
- package/dist/src/daemon/message-types/daemon-message.d.ts +2 -1
- package/dist/src/daemon/message-types/daemon-message.js +25 -2
- package/dist/src/daemon/sandbox-socket-hint.d.ts +27 -0
- package/dist/src/daemon/sandbox-socket-hint.js +136 -0
- package/dist/src/daemon/server/client-socket-context.d.ts +1 -1
- package/dist/src/daemon/server/client-socket-context.js +2 -3
- package/dist/src/daemon/server/dotenv-graph-changes.d.ts +97 -0
- package/dist/src/daemon/server/dotenv-graph-changes.js +284 -0
- package/dist/src/daemon/server/handle-client-env.d.ts +8 -0
- package/dist/src/daemon/server/handle-client-env.js +92 -0
- package/dist/src/daemon/server/handle-outputs-changes.d.ts +10 -0
- package/dist/src/daemon/server/handle-outputs-changes.js +86 -0
- package/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts +21 -0
- package/dist/src/daemon/server/project-graph-incremental-recomputation.js +159 -6
- package/dist/src/daemon/server/server.js +36 -72
- package/dist/src/daemon/server/shutdown-utils.d.ts +1 -1
- package/dist/src/daemon/server/shutdown-utils.js +2 -2
- package/dist/src/daemon/socket-utils.d.ts +26 -7
- package/dist/src/daemon/socket-utils.js +45 -31
- package/dist/src/daemon/tmp-dir.d.ts +10 -0
- package/dist/src/daemon/tmp-dir.js +21 -37
- package/dist/src/devkit-internals.d.ts +20 -9
- package/dist/src/devkit-internals.js +49 -6
- package/dist/src/executors/run-commands/running-tasks.js +46 -29
- package/dist/src/generators/internal-utils/{format-changed-files-with-prettier-if-available.d.ts → format-changed-files.d.ts} +6 -6
- package/dist/src/generators/internal-utils/format-changed-files.js +163 -0
- package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.d.ts +15 -0
- package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.js +21 -3
- package/dist/src/migrations/update-15-0-0/prefix-outputs.js +2 -2
- package/dist/src/migrations/update-16-0-0/remove-nrwl-cli.js +2 -2
- package/dist/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +2 -2
- package/dist/src/migrations/update-16-0-0/update-nx-cloud-runner.js +2 -2
- package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +2 -2
- package/dist/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +2 -2
- package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +2 -2
- package/dist/src/migrations/update-17-2-0/move-default-base.js +2 -2
- package/dist/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +2 -2
- package/dist/src/migrations/update-19-2-4/set-project-name.js +2 -2
- package/dist/src/migrations/update-20-0-0/move-use-daemon-process.js +2 -2
- package/dist/src/migrations/update-20-0-1/use-legacy-cache.js +2 -2
- package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.js +2 -2
- package/dist/src/migrations/update-21-0-0/release-version-config-changes.js +2 -2
- package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +2 -2
- package/dist/src/migrations/update-21-0-0/remove-legacy-cache.js +2 -2
- package/dist/src/migrations/update-22-0-0/consolidate-release-tag-config.js +2 -2
- package/dist/src/migrations/update-22-0-0/release-version-config-changes.js +2 -2
- package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.js +2 -2
- package/dist/src/migrations/update-22-6-0/add-claude-settings-local-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-22-7-0/add-polygraph-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +2 -2
- package/dist/src/native/index.d.ts +7 -3
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +3 -3
- package/dist/src/nx-cloud/utilities/url-shorten.d.ts +1 -4
- package/dist/src/nx-cloud/utilities/url-shorten.js +9 -8
- package/dist/src/plugins/js/lock-file/lock-file.d.ts +46 -4
- package/dist/src/plugins/js/lock-file/lock-file.js +192 -15
- package/dist/src/plugins/js/lock-file/npm-parser.js +10 -3
- package/dist/src/plugins/js/lock-file/pnpm-parser.js +356 -62
- package/dist/src/plugins/js/lock-file/project-graph-pruning.d.ts +25 -1
- package/dist/src/plugins/js/lock-file/project-graph-pruning.js +78 -4
- package/dist/src/plugins/js/lock-file/pruned-output.d.ts +330 -0
- package/dist/src/plugins/js/lock-file/pruned-output.js +1441 -0
- package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +1 -0
- package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +6 -5
- package/dist/src/plugins/js/utils/register.d.ts +11 -0
- package/dist/src/plugins/js/utils/register.js +40 -6
- package/dist/src/project-graph/plugins/get-plugins.d.ts +27 -1
- package/dist/src/project-graph/plugins/get-plugins.js +110 -5
- package/dist/src/project-graph/plugins/isolation/enabled.js +1 -4
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +16 -0
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +69 -11
- package/dist/src/project-graph/plugins/isolation/messaging.js +1 -3
- package/dist/src/project-graph/plugins/isolation/plugin-worker.js +23 -2
- package/dist/src/project-graph/project-graph.js +27 -2
- package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts +7 -0
- package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.js +14 -6
- package/dist/src/project-graph/utils/project-configuration/target-defaults.js +47 -21
- package/dist/src/tasks-runner/is-tui-enabled.js +3 -1
- package/dist/src/tasks-runner/life-cycle.d.ts +2 -2
- package/dist/src/tasks-runner/life-cycle.js +2 -2
- package/dist/src/tasks-runner/life-cycles/performance-report.d.ts +12 -0
- package/dist/src/tasks-runner/life-cycles/performance-report.js +62 -3
- package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.d.ts +26 -1
- package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +99 -5
- package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.d.ts +26 -0
- package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +113 -17
- package/dist/src/tasks-runner/pseudo-ipc.js +14 -13
- package/dist/src/tasks-runner/pseudo-terminal.d.ts +17 -3
- package/dist/src/tasks-runner/pseudo-terminal.js +22 -10
- package/dist/src/tasks-runner/run-command.js +32 -39
- package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +55 -0
- package/dist/src/tasks-runner/running-tasks/batch-process.js +161 -8
- package/dist/src/tasks-runner/task-env.d.ts +25 -0
- package/dist/src/tasks-runner/task-env.js +39 -0
- package/dist/src/tasks-runner/task-orchestrator.d.ts +68 -0
- package/dist/src/tasks-runner/task-orchestrator.js +159 -8
- package/dist/src/utils/analytics-enabled.d.ts +7 -0
- package/dist/src/utils/analytics-enabled.js +11 -0
- package/dist/src/utils/analytics-prompt.js +4 -7
- package/dist/src/utils/cache-directory.d.ts +62 -3
- package/dist/src/utils/cache-directory.js +276 -25
- package/dist/src/utils/catalog/bun-manager-utils.d.ts +8 -0
- package/dist/src/utils/catalog/bun-manager-utils.js +174 -0
- package/dist/src/utils/catalog/bun-manager.d.ts +28 -0
- package/dist/src/utils/catalog/bun-manager.js +130 -0
- package/dist/src/utils/catalog/index.d.ts +1 -1
- package/dist/src/utils/catalog/index.js +1 -1
- package/dist/src/utils/catalog/manager-factory.js +3 -0
- package/dist/src/utils/catalog/manager-utils.d.ts +8 -1
- package/dist/src/utils/catalog/manager-utils.js +9 -4
- package/dist/src/utils/catalog/manager.d.ts +13 -1
- package/dist/src/utils/catalog/manager.js +30 -0
- package/dist/src/utils/catalog/pnpm-manager.d.ts +2 -1
- package/dist/src/utils/catalog/pnpm-manager.js +3 -0
- package/dist/src/utils/catalog/types.d.ts +4 -0
- package/dist/src/utils/catalog/yarn-manager.d.ts +6 -2
- package/dist/src/utils/catalog/yarn-manager.js +23 -32
- package/dist/src/utils/child-process.d.ts +31 -1
- package/dist/src/utils/child-process.js +103 -0
- package/dist/src/utils/chunkify.d.ts +7 -1
- package/dist/src/utils/chunkify.js +10 -3
- package/dist/src/utils/consume-messages-from-socket.d.ts +42 -7
- package/dist/src/utils/consume-messages-from-socket.js +273 -38
- package/dist/src/utils/db-connection.js +8 -16
- package/dist/src/utils/exit-codes.d.ts +9 -0
- package/dist/src/utils/exit-codes.js +19 -0
- package/dist/src/utils/formatters/index.d.ts +13 -0
- package/dist/src/utils/formatters/index.js +74 -0
- package/dist/src/utils/formatters/oxfmt.d.ts +32 -0
- package/dist/src/utils/formatters/oxfmt.js +764 -0
- package/dist/src/utils/formatters/prettier.d.ts +26 -0
- package/dist/src/utils/formatters/prettier.js +201 -0
- package/dist/src/utils/formatters/shared.d.ts +5 -0
- package/dist/src/utils/formatters/shared.js +8 -0
- package/dist/src/utils/git-utils.d.ts +38 -2
- package/dist/src/utils/git-utils.js +422 -19
- package/dist/src/utils/has-nx-js-plugin.d.ts +1 -1
- package/dist/src/utils/has-nx-js-plugin.js +1 -1
- package/dist/src/utils/ignore.d.ts +47 -5
- package/dist/src/utils/ignore.js +93 -11
- package/dist/src/utils/kill-child-on-host-exit.d.ts +7 -0
- package/dist/src/utils/kill-child-on-host-exit.js +42 -0
- package/dist/src/utils/nx-console-prompt.js +3 -6
- package/dist/src/utils/nx-tmp-dir.d.ts +5 -0
- package/dist/src/utils/nx-tmp-dir.js +7 -2
- package/dist/src/utils/output.d.ts +153 -0
- package/dist/src/utils/output.js +289 -5
- package/dist/src/utils/owned-private-dir.d.ts +13 -0
- package/dist/src/utils/owned-private-dir.js +39 -0
- package/dist/src/utils/package-json.d.ts +2 -0
- package/dist/src/utils/package-manager.js +17 -7
- package/dist/src/utils/params.d.ts +7 -1
- package/dist/src/utils/params.js +64 -6
- package/dist/src/utils/permission-errors.d.ts +11 -0
- package/dist/src/utils/permission-errors.js +17 -0
- package/dist/src/utils/plugins/core-plugins.js +4 -0
- package/dist/src/utils/prompt-helpers.d.ts +53 -0
- package/dist/src/utils/prompt-helpers.js +111 -0
- package/dist/src/utils/socket-refused-exit-code.d.ts +15 -0
- package/dist/src/utils/socket-refused-exit-code.js +18 -0
- package/dist/src/utils/write-formatted-json-file.d.ts +3 -2
- package/dist/src/utils/write-formatted-json-file.js +5 -4
- package/package.json +33 -24
- package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +0 -88
- package/dist/src/utils/is-using-prettier.d.ts +0 -3
- package/dist/src/utils/is-using-prettier.js +0 -62
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._setEnvForwardTimeoutMs = _setEnvForwardTimeoutMs;
|
|
4
|
+
exports.handleClientEnv = handleClientEnv;
|
|
5
|
+
const get_plugins_1 = require("../../project-graph/plugins/get-plugins");
|
|
6
|
+
const daemon_environment_1 = require("../client/daemon-environment");
|
|
7
|
+
const logger_1 = require("../logger");
|
|
8
|
+
const project_graph_incremental_recomputation_1 = require("./project-graph-incremental-recomputation");
|
|
9
|
+
// Bounds the wait for worker acknowledgements so a wedged worker cannot hold
|
|
10
|
+
// every env-carrying client message for the 10-minute plugin-hook timeout. A
|
|
11
|
+
// healthy worker applies the env synchronously and acks in milliseconds.
|
|
12
|
+
let envForwardTimeoutMs = 10_000;
|
|
13
|
+
// Test seam: the production timeout would stall the suite.
|
|
14
|
+
function _setEnvForwardTimeoutMs(ms) {
|
|
15
|
+
envForwardTimeoutMs = ms;
|
|
16
|
+
}
|
|
17
|
+
let inFlightApply;
|
|
18
|
+
/**
|
|
19
|
+
* Applies an env-carrying client message to the daemon. Must be awaited
|
|
20
|
+
* before dispatching the message's handler: plugin workers key their disk
|
|
21
|
+
* caches on their own process env, so a graph request must not reach a worker
|
|
22
|
+
* whose env still reflects the previous client.
|
|
23
|
+
*/
|
|
24
|
+
async function handleClientEnv(env) {
|
|
25
|
+
// A client whose env matches one an in-flight apply already wrote to
|
|
26
|
+
// process.env sees zero changed keys, yet the graph cache is only discarded
|
|
27
|
+
// once that apply's forwarding completes. Wait for it so such a client
|
|
28
|
+
// cannot be served the graph computed under the previous env.
|
|
29
|
+
while (inFlightApply) {
|
|
30
|
+
await inFlightApply;
|
|
31
|
+
}
|
|
32
|
+
const changedEnvKeys = (0, daemon_environment_1.applyDaemonEnvFromClient)(env);
|
|
33
|
+
if (changedEnvKeys.length === 0) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
logger_1.serverLogger.log(`Graph recompute necessary due to env variable refresh. Changed keys: ${changedEnvKeys.join(', ')}`);
|
|
37
|
+
const apply = applyEnvChange(env);
|
|
38
|
+
inFlightApply = apply;
|
|
39
|
+
try {
|
|
40
|
+
await apply;
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
if (inFlightApply === apply) {
|
|
44
|
+
inFlightApply = undefined;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function applyEnvChange(env) {
|
|
49
|
+
await forwardEnvToPluginWorkers(env);
|
|
50
|
+
// Discarding the cached graph makes the next request recompute under the
|
|
51
|
+
// new env, and chains any in-flight compute (started under the old env) to
|
|
52
|
+
// that successor.
|
|
53
|
+
(0, project_graph_incremental_recomputation_1.invalidateGraphCache)();
|
|
54
|
+
}
|
|
55
|
+
// Covers committed workers and an in-flight load, whose workers forked under
|
|
56
|
+
// the previous env before this apply and would otherwise keep it for good. A
|
|
57
|
+
// load started after this needs no forwarding: its workers fork with the
|
|
58
|
+
// daemon's already-updated process.env. Each forward settles rather than
|
|
59
|
+
// rejects so one dead worker (or a failed load) cannot fail every env-carrying
|
|
60
|
+
// client message. Timing out is safe: each worker socket delivers the already
|
|
61
|
+
// sent env update before any later graph message, and the plugin cache write
|
|
62
|
+
// guard drops a pass the update lands in the middle of.
|
|
63
|
+
async function forwardEnvToPluginWorkers(env) {
|
|
64
|
+
let timer;
|
|
65
|
+
const timedOut = await Promise.race([
|
|
66
|
+
forwardEnvToPluginWorkersUnbounded(env).then(() => false),
|
|
67
|
+
new Promise((resolve) => {
|
|
68
|
+
timer = setTimeout(() => resolve(true), envForwardTimeoutMs);
|
|
69
|
+
timer.unref();
|
|
70
|
+
}),
|
|
71
|
+
]).finally(() => clearTimeout(timer));
|
|
72
|
+
if (timedOut) {
|
|
73
|
+
logger_1.serverLogger.log(`Timed out forwarding the new env to plugin workers after ${envForwardTimeoutMs}ms; continuing without their acknowledgement.`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async function forwardEnvToPluginWorkersUnbounded(env) {
|
|
77
|
+
const pluginsPromise = (0, get_plugins_1.getPluginsIfLoadedOrLoading)();
|
|
78
|
+
if (!pluginsPromise) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
let plugins;
|
|
82
|
+
try {
|
|
83
|
+
plugins = await pluginsPromise;
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
// The load failed, so there are no workers to forward to.
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
await Promise.all(plugins.map((plugin) => plugin.setWorkerEnv?.(env)?.catch((e) => {
|
|
90
|
+
logger_1.serverLogger.log(`Failed to forward env to plugin worker "${plugin.name}": ${e.message}`);
|
|
91
|
+
})));
|
|
92
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FileWatcherCallback } from './watcher';
|
|
2
|
+
/**
|
|
3
|
+
* The error a native outputs watcher failure delivered, if one has. Such an
|
|
4
|
+
* error is terminal (the native watch loop exits after delivering it), so the
|
|
5
|
+
* gitignored dotenv edits only that watcher reports stop arriving and a warm
|
|
6
|
+
* graph would go stale silently. The server fails requests closed on it, like
|
|
7
|
+
* a workspace watcher error.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getOutputsWatcherTerminalError(): Error | undefined;
|
|
10
|
+
export declare const handleOutputsChanges: FileWatcherCallback;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleOutputsChanges = void 0;
|
|
4
|
+
exports.getOutputsWatcherTerminalError = getOutputsWatcherTerminalError;
|
|
5
|
+
const logger_1 = require("../logger");
|
|
6
|
+
const dotenv_graph_changes_1 = require("./dotenv-graph-changes");
|
|
7
|
+
const outputs_tracking_1 = require("./outputs-tracking");
|
|
8
|
+
const project_graph_incremental_recomputation_1 = require("./project-graph-incremental-recomputation");
|
|
9
|
+
let outputsWatcherError;
|
|
10
|
+
let outputsWatcherTerminalError;
|
|
11
|
+
/**
|
|
12
|
+
* The error a native outputs watcher failure delivered, if one has. Such an
|
|
13
|
+
* error is terminal (the native watch loop exits after delivering it), so the
|
|
14
|
+
* gitignored dotenv edits only that watcher reports stop arriving and a warm
|
|
15
|
+
* graph would go stale silently. The server fails requests closed on it, like
|
|
16
|
+
* a workspace watcher error.
|
|
17
|
+
*/
|
|
18
|
+
function getOutputsWatcherTerminalError() {
|
|
19
|
+
return outputsWatcherTerminalError;
|
|
20
|
+
}
|
|
21
|
+
const handleOutputsChanges = async (err, changeEvents) => {
|
|
22
|
+
try {
|
|
23
|
+
if (err || !changeEvents || !changeEvents.length) {
|
|
24
|
+
let error = typeof err === 'string' ? new Error(err) : err;
|
|
25
|
+
logger_1.serverLogger.watcherLog('Unexpected outputs watcher error', error.message);
|
|
26
|
+
console.error(error);
|
|
27
|
+
outputsWatcherError = error;
|
|
28
|
+
(0, outputs_tracking_1.disableOutputsTracking)();
|
|
29
|
+
if (err) {
|
|
30
|
+
// A native error is terminal: the watch loop has exited, so the
|
|
31
|
+
// gitignored dotenv edits only this watcher reports stop arriving and
|
|
32
|
+
// the graph invalidation below can never run again. Fail requests
|
|
33
|
+
// closed like a workspace watcher error rather than serving a graph
|
|
34
|
+
// that silently goes stale. The original error is preserved so an
|
|
35
|
+
// inotify_add_watch failure still makes the client disable the daemon
|
|
36
|
+
// and rebuild without it.
|
|
37
|
+
outputsWatcherTerminalError = error;
|
|
38
|
+
}
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
// A dotenv change that a task chain loads must refresh the graph so
|
|
42
|
+
// createNodes re-resolves config reading process.env. This runs above the
|
|
43
|
+
// outputsWatcherError guard: the two concerns are independent, and a
|
|
44
|
+
// disabled outputs tracker must not leave the graph stale on a dotenv edit.
|
|
45
|
+
// A change to a file the workspace watcher tracks already schedules a
|
|
46
|
+
// recomputation that reads the new content; invalidating for it here too
|
|
47
|
+
// would discard that recomputation at commit and force a second one. It is
|
|
48
|
+
// queued instead of dropped: the two watchers deliver independently, so a
|
|
49
|
+
// computation already in flight may have read the file before the edit,
|
|
50
|
+
// and only the pre-serve replay can prove that. The committed file map
|
|
51
|
+
// approximates what the watcher tracks: a file it does not know is either
|
|
52
|
+
// gitignored (never reaches the workspace watcher, so it needs the
|
|
53
|
+
// invalidation) or created since the last recompute (the watcher handles
|
|
54
|
+
// it; the extra invalidation is fail-safe). Its own try/catch so a fault
|
|
55
|
+
// here cannot trip the outputs-tracking kill switch below, which belongs
|
|
56
|
+
// to an unrelated subsystem, and it fails safe by invalidating: a stale
|
|
57
|
+
// graph on a dotenv edit is the bug this prevents.
|
|
58
|
+
try {
|
|
59
|
+
const { invalidating, unclassified } = (0, dotenv_graph_changes_1.classifyDotEnvChanges)(changeEvents, project_graph_incremental_recomputation_1.currentProjectGraph);
|
|
60
|
+
const generation = (0, project_graph_incremental_recomputation_1.getRecomputationGeneration)();
|
|
61
|
+
(0, dotenv_graph_changes_1.queuePendingDotEnvEvents)(unclassified.map((event) => event.path), generation);
|
|
62
|
+
const knownInvalidating = invalidating.filter((path) => (0, project_graph_incremental_recomputation_1.isKnownWorkspaceFile)(path));
|
|
63
|
+
(0, dotenv_graph_changes_1.queuePendingDotEnvEvents)(knownInvalidating, generation);
|
|
64
|
+
if (knownInvalidating.length < invalidating.length) {
|
|
65
|
+
(0, project_graph_incremental_recomputation_1.invalidateGraphCache)();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
logger_1.serverLogger.watcherLog('Failed to evaluate dotenv changes for graph invalidation; invalidating the graph cache to be safe', e instanceof Error ? e.message : String(e));
|
|
70
|
+
console.error(e);
|
|
71
|
+
(0, project_graph_incremental_recomputation_1.invalidateGraphCache)();
|
|
72
|
+
}
|
|
73
|
+
if (outputsWatcherError) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
logger_1.serverLogger.watcherLog('Processing file changes in outputs');
|
|
77
|
+
(0, outputs_tracking_1.processFileChangesInOutputs)(changeEvents);
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
logger_1.serverLogger.watcherLog(`Unexpected outputs watcher error`, err.message);
|
|
81
|
+
console.error(err);
|
|
82
|
+
outputsWatcherError = err;
|
|
83
|
+
(0, outputs_tracking_1.disableOutputsTracking)();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
exports.handleOutputsChanges = handleOutputsChanges;
|
|
@@ -22,5 +22,26 @@ export declare let currentSourceMaps: ConfigurationSourceMaps | undefined;
|
|
|
22
22
|
export declare function getCachedSerializedProjectGraphPromise(socket?: Socket): Promise<SerializedProjectGraph>;
|
|
23
23
|
export declare function scheduleProjectGraphRecomputation(createdFiles: string[], updatedFiles: string[], deletedFiles: string[]): void;
|
|
24
24
|
export declare function registerProjectGraphRecomputationListener(listener: (projectGraph: ProjectGraph, sourceMaps: ConfigurationSourceMaps, error: Error | null) => void): void;
|
|
25
|
+
/**
|
|
26
|
+
* Discards the cached graph when a graph input outside the file watcher's view
|
|
27
|
+
* (e.g. the daemon env) changes. Clearing the cached promise makes the next
|
|
28
|
+
* request trigger a fresh computation; the generation bump marks any in-flight
|
|
29
|
+
* compute stale so it chains to that successor instead of committing, because
|
|
30
|
+
* a compute passing its chainToLatest checks would serve a graph built under
|
|
31
|
+
* the old input to whoever already awaits it.
|
|
32
|
+
*/
|
|
25
33
|
export declare function invalidateGraphCache(): void;
|
|
34
|
+
/**
|
|
35
|
+
* The current recomputation generation, stamped on queued dotenv events so
|
|
36
|
+
* the pre-serve drain can prove whether a computation started before an
|
|
37
|
+
* event arrived.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getRecomputationGeneration(): number;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the ignore-filtered workspace file map knows `path`. The workspace
|
|
42
|
+
* watcher applies the same ignore rules, so a change to a known file also
|
|
43
|
+
* reaches scheduleProjectGraphRecomputation; an unknown file is either
|
|
44
|
+
* ignored, or created since the last recompute committed.
|
|
45
|
+
*/
|
|
46
|
+
export declare function isKnownWorkspaceFile(path: string): boolean;
|
|
26
47
|
export {};
|
|
@@ -5,6 +5,8 @@ exports.getCachedSerializedProjectGraphPromise = getCachedSerializedProjectGraph
|
|
|
5
5
|
exports.scheduleProjectGraphRecomputation = scheduleProjectGraphRecomputation;
|
|
6
6
|
exports.registerProjectGraphRecomputationListener = registerProjectGraphRecomputationListener;
|
|
7
7
|
exports.invalidateGraphCache = invalidateGraphCache;
|
|
8
|
+
exports.getRecomputationGeneration = getRecomputationGeneration;
|
|
9
|
+
exports.isKnownWorkspaceFile = isKnownWorkspaceFile;
|
|
8
10
|
const perf_hooks_1 = require("perf_hooks");
|
|
9
11
|
const nx_json_1 = require("../../config/nx-json");
|
|
10
12
|
const file_hasher_1 = require("../../hasher/file-hasher");
|
|
@@ -19,6 +21,7 @@ const workspace_context_1 = require("../../utils/workspace-context");
|
|
|
19
21
|
const workspace_root_1 = require("../../utils/workspace-root");
|
|
20
22
|
const progress_topics_1 = require("../../utils/progress-topics");
|
|
21
23
|
const client_socket_context_1 = require("./client-socket-context");
|
|
24
|
+
const dotenv_graph_changes_1 = require("./dotenv-graph-changes");
|
|
22
25
|
const file_change_events_1 = require("./file-watching/file-change-events");
|
|
23
26
|
const file_watcher_sockets_1 = require("./file-watching/file-watcher-sockets");
|
|
24
27
|
const project_graph_listener_sockets_1 = require("./project-graph-listener-sockets");
|
|
@@ -34,6 +37,18 @@ let storedWorkspaceConfigHash;
|
|
|
34
37
|
let knownExternalNodes = {};
|
|
35
38
|
let fileChangeCounter = 0;
|
|
36
39
|
let recomputationGeneration = 0;
|
|
40
|
+
// The graph the settled cached promise serves, with the generation its
|
|
41
|
+
// computation claimed. Set only when a computation's own success becomes the
|
|
42
|
+
// cached result; any newer kickoff or invalidation clears it, so non-null
|
|
43
|
+
// means the cached promise is settled and this is exactly what it serves. The
|
|
44
|
+
// warm-reuse dotenv check classifies against this, never against
|
|
45
|
+
// `currentProjectGraph`: a slow stale computation overwrites that after the
|
|
46
|
+
// winner settles and only then chains away. The candidate is written by the
|
|
47
|
+
// computation itself (which knows its generation) and promoted by
|
|
48
|
+
// kickOffRecompute after the outer plugin-hash and cached-pointer identity
|
|
49
|
+
// checks, which can still reject the result.
|
|
50
|
+
let servedGraphState = null;
|
|
51
|
+
let servedGraphCandidate = null;
|
|
37
52
|
// True after the first successful persistProjectGraphToDisk call. Until
|
|
38
53
|
// that happens, "project-graph.json missing on disk" is the expected
|
|
39
54
|
// state (we just haven't written it yet) and must not trigger a reset.
|
|
@@ -47,6 +62,9 @@ let cacheHasBeenPersisted = false;
|
|
|
47
62
|
* (see spread.test.ts "middle plugin" flake).
|
|
48
63
|
*/
|
|
49
64
|
function kickOffRecompute() {
|
|
65
|
+
// The cached pointer is about to hold an unsettled promise, so whatever the
|
|
66
|
+
// previous state described is no longer what the cache serves.
|
|
67
|
+
servedGraphState = null;
|
|
50
68
|
let myPromise;
|
|
51
69
|
myPromise = (async () => {
|
|
52
70
|
// Must resolve, never reject: kickOffRecompute() runs fire-and-forget, so
|
|
@@ -69,6 +87,12 @@ function kickOffRecompute() {
|
|
|
69
87
|
return chainToSuccessor(myPromise);
|
|
70
88
|
if (cachedSerializedProjectGraphPromise === myPromise &&
|
|
71
89
|
result.projectGraph) {
|
|
90
|
+
// The graph identity ties the candidate's generation to exactly this
|
|
91
|
+
// result; a chained result never matches (its computation's kickoff
|
|
92
|
+
// replaced the cached pointer, failing the identity check above).
|
|
93
|
+
if (servedGraphCandidate?.graph === result.projectGraph) {
|
|
94
|
+
servedGraphState = servedGraphCandidate;
|
|
95
|
+
}
|
|
72
96
|
notifyProjectGraphRecomputationListeners(result.projectGraph, result.sourceMaps, result.error);
|
|
73
97
|
persistProjectGraphToDisk(result);
|
|
74
98
|
}
|
|
@@ -121,6 +145,28 @@ async function getCachedSerializedProjectGraphPromise(socket) {
|
|
|
121
145
|
// stale graph. Placed right before the read so no microtask gap
|
|
122
146
|
// separates them.
|
|
123
147
|
await new Promise(setImmediate);
|
|
148
|
+
// The queue can hold evidence against the settled cached graph itself: a
|
|
149
|
+
// tracked dotenv edit only the outputs watcher has delivered yet queues
|
|
150
|
+
// without invalidating, and the workspace watcher's recomputation may lag
|
|
151
|
+
// this request. Classified against the exact graph the cache serves; an
|
|
152
|
+
// in-flight computation needs no check here because its own pre-serve
|
|
153
|
+
// replay consumes the queue. Content hashes are dropped before the
|
|
154
|
+
// successor can read, as in the error retry: one recorded when the edit
|
|
155
|
+
// was classified could suppress a revert landing mid-read. Fails toward
|
|
156
|
+
// recomputing, since a stale graph on a dotenv edit is the bug this
|
|
157
|
+
// prevents.
|
|
158
|
+
try {
|
|
159
|
+
if (servedGraphState &&
|
|
160
|
+
(0, dotenv_graph_changes_1.hasRelevantPendingDotEnvEvidence)(servedGraphState.graph, servedGraphState.generation)) {
|
|
161
|
+
(0, dotenv_graph_changes_1.clearDotEnvFileHashes)();
|
|
162
|
+
invalidateGraphCache();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
catch (e) {
|
|
166
|
+
logger_1.serverLogger.log(`Failed to check pending dotenv changes against the cached graph; recomputing to be safe: ${e instanceof Error ? e.message : e}`);
|
|
167
|
+
(0, dotenv_graph_changes_1.clearDotEnvFileHashes)();
|
|
168
|
+
invalidateGraphCache();
|
|
169
|
+
}
|
|
124
170
|
// If no compute exists or events are still in collected*, kick one off.
|
|
125
171
|
// Otherwise reuse whatever is already in flight or cached.
|
|
126
172
|
const needsRecompute = !cachedSerializedProjectGraphPromise ||
|
|
@@ -266,13 +312,60 @@ async function processCollectedUpdatedAndDeletedFiles({ projects, externalNodes,
|
|
|
266
312
|
throw e;
|
|
267
313
|
}
|
|
268
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* Discards the cached graph when a graph input outside the file watcher's view
|
|
317
|
+
* (e.g. the daemon env) changes. Clearing the cached promise makes the next
|
|
318
|
+
* request trigger a fresh computation; the generation bump marks any in-flight
|
|
319
|
+
* compute stale so it chains to that successor instead of committing, because
|
|
320
|
+
* a compute passing its chainToLatest checks would serve a graph built under
|
|
321
|
+
* the old input to whoever already awaits it.
|
|
322
|
+
*/
|
|
269
323
|
function invalidateGraphCache() {
|
|
270
|
-
// Clear the cached promise so the next request triggers a fresh computation.
|
|
271
324
|
// We intentionally do NOT call getCachedSerializedProjectGraphPromise() here
|
|
272
325
|
// because assigning its return Promise to the module-level variable causes a
|
|
273
326
|
// deadlock: the async function resumes, sees the variable is non-null (pointing
|
|
274
327
|
// at its own Promise), takes the "reuse" branch, and awaits itself forever.
|
|
275
328
|
cachedSerializedProjectGraphPromise = null;
|
|
329
|
+
++recomputationGeneration;
|
|
330
|
+
servedGraphState = null;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* The current recomputation generation, stamped on queued dotenv events so
|
|
334
|
+
* the pre-serve drain can prove whether a computation started before an
|
|
335
|
+
* event arrived.
|
|
336
|
+
*/
|
|
337
|
+
function getRecomputationGeneration() {
|
|
338
|
+
return recomputationGeneration;
|
|
339
|
+
}
|
|
340
|
+
// isKnownWorkspaceFile's membership set, derived lazily from the map object it
|
|
341
|
+
// was built from; every `fileMapWithFiles` write clears it, so a replaced map
|
|
342
|
+
// generation is not retained through the memo.
|
|
343
|
+
let knownWorkspaceFiles;
|
|
344
|
+
let knownWorkspaceFilesSource;
|
|
345
|
+
/**
|
|
346
|
+
* Whether the ignore-filtered workspace file map knows `path`. The workspace
|
|
347
|
+
* watcher applies the same ignore rules, so a change to a known file also
|
|
348
|
+
* reaches scheduleProjectGraphRecomputation; an unknown file is either
|
|
349
|
+
* ignored, or created since the last recompute committed.
|
|
350
|
+
*/
|
|
351
|
+
function isKnownWorkspaceFile(path) {
|
|
352
|
+
if (!exports.fileMapWithFiles) {
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
if (knownWorkspaceFilesSource !== exports.fileMapWithFiles) {
|
|
356
|
+
const { projectFileMap, nonProjectFiles } = exports.fileMapWithFiles.fileMap;
|
|
357
|
+
knownWorkspaceFiles = new Set();
|
|
358
|
+
for (const { file } of nonProjectFiles) {
|
|
359
|
+
knownWorkspaceFiles.add(file);
|
|
360
|
+
}
|
|
361
|
+
for (const files of Object.values(projectFileMap)) {
|
|
362
|
+
for (const { file } of files) {
|
|
363
|
+
knownWorkspaceFiles.add(file);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
knownWorkspaceFilesSource = exports.fileMapWithFiles;
|
|
367
|
+
}
|
|
368
|
+
return knownWorkspaceFiles.has(path);
|
|
276
369
|
}
|
|
277
370
|
async function processFilesAndCreateAndSerializeProjectGraph(separatedPlugins) {
|
|
278
371
|
const plugins = [
|
|
@@ -280,6 +373,14 @@ async function processFilesAndCreateAndSerializeProjectGraph(separatedPlugins) {
|
|
|
280
373
|
...separatedPlugins.defaultPlugins,
|
|
281
374
|
];
|
|
282
375
|
const myGeneration = ++recomputationGeneration;
|
|
376
|
+
// A hash recorded before this claim can describe bytes this computation
|
|
377
|
+
// never reads (a callback classified between a forced invalidation and this
|
|
378
|
+
// claim records one no handler-side clear has seen), and retained it could
|
|
379
|
+
// suppress a coalesced revert landing mid-read. Bounding every hash to the
|
|
380
|
+
// window since the last claim closes that for any successor, however it was
|
|
381
|
+
// forced. A callback landing after this claim re-records and re-queues, and
|
|
382
|
+
// its stamp then marks this computation stale at the drain.
|
|
383
|
+
(0, dotenv_graph_changes_1.clearDotEnvFileHashes)();
|
|
283
384
|
// A newer kickOffRecompute has already replaced
|
|
284
385
|
// cachedSerializedProjectGraphPromise. Returning it lets the async
|
|
285
386
|
// unwrap chain our caller onto the newer compute's result; pass
|
|
@@ -341,6 +442,8 @@ async function processFilesAndCreateAndSerializeProjectGraph(separatedPlugins) {
|
|
|
341
442
|
// chainToLatest above without touching `fileMapWithFiles`, so they
|
|
342
443
|
// can't clobber a newer compute's write.
|
|
343
444
|
exports.fileMapWithFiles = fileMapUpdate.fileMap;
|
|
445
|
+
knownWorkspaceFiles = undefined;
|
|
446
|
+
knownWorkspaceFilesSource = undefined;
|
|
344
447
|
storedWorkspaceConfigHash = fileMapUpdate.configHash;
|
|
345
448
|
if (fileMapUpdate.knownExternalNodes) {
|
|
346
449
|
knownExternalNodes = fileMapUpdate.knownExternalNodes;
|
|
@@ -373,13 +476,59 @@ async function processFilesAndCreateAndSerializeProjectGraph(separatedPlugins) {
|
|
|
373
476
|
const aggregate = g.error && (0, error_types_1.isAggregateProjectGraphError)(g.error) && g.error.errors?.length
|
|
374
477
|
? g.error
|
|
375
478
|
: null;
|
|
376
|
-
|
|
377
|
-
|
|
479
|
+
// An error result is never cached, notified, or persisted, so a queued
|
|
480
|
+
// dotenv edit that may already have fixed the failing input earns one
|
|
481
|
+
// retry instead of surfacing the error. The peek consumes nothing (a
|
|
482
|
+
// successful successor's drain classifies the entries against a real
|
|
483
|
+
// graph, which these branches may lack: `g.projectGraph` can be null
|
|
484
|
+
// here) and a persistent error retries once, because the successor
|
|
485
|
+
// claims a generation above every recorded stamp. Content hashes are
|
|
486
|
+
// dropped, though: one recorded during this failed computation could
|
|
487
|
+
// suppress a callback landing while the successor reads. The catch at
|
|
488
|
+
// the end of this function stays excluded: a throw there can predate
|
|
489
|
+
// projectConfigurationsResult and the plugin hooks' balancing, and the
|
|
490
|
+
// next request recomputes at a fresh generation anyway.
|
|
491
|
+
const retryForPendingDotEnv = () => {
|
|
492
|
+
if (!(0, dotenv_graph_changes_1.hasPendingDotEnvEvidence)(myGeneration))
|
|
493
|
+
return null;
|
|
494
|
+
(0, dotenv_graph_changes_1.clearDotEnvFileHashes)();
|
|
495
|
+
invalidateGraphCache();
|
|
496
|
+
return chainToLatest(false);
|
|
497
|
+
};
|
|
498
|
+
if (g.error && !aggregate) {
|
|
499
|
+
return retryForPendingDotEnv() ?? errorResult(g.error);
|
|
500
|
+
}
|
|
378
501
|
if (aggregate)
|
|
379
502
|
errors.push(...aggregate.errors);
|
|
380
|
-
if (errors.length
|
|
381
|
-
return
|
|
382
|
-
|
|
503
|
+
if (errors.length > 0) {
|
|
504
|
+
return (retryForPendingDotEnv() ??
|
|
505
|
+
errorResult(new error_types_1.DaemonProjectGraphError(errors, g.projectGraph, projectConfigurationsResult.sourceMaps)));
|
|
506
|
+
}
|
|
507
|
+
// Replay the dotenv events no committed root could classify on arrival
|
|
508
|
+
// against the graph about to be served. Runs after the last staleness
|
|
509
|
+
// gate so a stale compute leaves the queue for its successor, and only
|
|
510
|
+
// on the success path: an error result is never notified or persisted.
|
|
511
|
+
// Queue evidence is decisive here even for files the workspace watcher
|
|
512
|
+
// tracks: the two watchers deliver independently, so tracking alone does
|
|
513
|
+
// not prove that watcher's recomputation was already scheduled.
|
|
514
|
+
let staleDotEnv;
|
|
515
|
+
try {
|
|
516
|
+
const pending = (0, dotenv_graph_changes_1.drainPendingDotEnvEvents)(g.projectGraph, myGeneration);
|
|
517
|
+
staleDotEnv = pending.overflowed || pending.invalidating.length > 0;
|
|
518
|
+
}
|
|
519
|
+
catch (e) {
|
|
520
|
+
logger_1.serverLogger.log(`Failed to re-check pending dotenv changes; recomputing to be safe: ${e instanceof Error ? e.message : e}`);
|
|
521
|
+
staleDotEnv = true;
|
|
522
|
+
}
|
|
523
|
+
if (staleDotEnv) {
|
|
524
|
+
// This graph read the file before the queued edit landed. The bump plus
|
|
525
|
+
// chain hands every awaiting caller the successor's result and keeps
|
|
526
|
+
// this one from being notified or persisted.
|
|
527
|
+
invalidateGraphCache();
|
|
528
|
+
return chainToLatest(false);
|
|
529
|
+
}
|
|
530
|
+
servedGraphCandidate = { graph: g.projectGraph, generation: myGeneration };
|
|
531
|
+
return g;
|
|
383
532
|
}
|
|
384
533
|
catch (err) {
|
|
385
534
|
return errorResult(err);
|
|
@@ -464,7 +613,11 @@ async function createAndSerializeProjectGraph({ projects, sourceMaps, }) {
|
|
|
464
613
|
}
|
|
465
614
|
async function resetInternalState() {
|
|
466
615
|
cachedSerializedProjectGraphPromise = undefined;
|
|
616
|
+
servedGraphState = null;
|
|
617
|
+
servedGraphCandidate = null;
|
|
467
618
|
exports.fileMapWithFiles = undefined;
|
|
619
|
+
knownWorkspaceFiles = undefined;
|
|
620
|
+
knownWorkspaceFilesSource = undefined;
|
|
468
621
|
exports.currentProjectFileMapCache = undefined;
|
|
469
622
|
exports.currentProjectGraph = undefined;
|
|
470
623
|
exports.currentSourceMaps = undefined;
|