The Open Framework for Building Agents
test(eve): repro module map publish failing without hard links (#4732)
roboeve[bot]8d5b75f8632e
diff --git a/.changeset/module-map-without-hard-links.md b/.changeset/module-map-without-hard-links.mdnew file mode 100644index 000000000..3a8b914ca--- /dev/null+++ b/.changeset/module-map-without-hard-links.md@@ -0,0 +1,5 @@+---+"eve": patch+---++`eve build` now works for apps with mounted extensions on filesystems without hard-link support, such as some NFS and FUSE mounts. It no longer fails with `Unknown system error -524` while writing the authored module map.diff --git a/packages/eve/src/internal/authored-module-map-loader.integration.test.ts b/packages/eve/src/internal/authored-module-map-loader.integration.test.tsnew file mode 100644index 000000000..9c7b21909--- /dev/null+++ b/packages/eve/src/internal/authored-module-map-loader.integration.test.ts@@ -0,0 +1,53 @@+import { describe, expect, it, vi } from "vitest";++import { compileAgent } from "#compiler/compile-agent.js";+import { ROOT_COMPILED_AGENT_NODE_ID } from "#compiler/manifest.js";+import { loadCompiledModuleMapFromAuthoredSource } from "#internal/authored-module-map-loader.js";+import { useTemporaryAppRoots } from "#internal/testing/use-temporary-app-roots.js";+import { createDiskRuntimeCompiledArtifactsSource } from "#runtime/compiled-artifacts-source.js";+import { loadCompiledManifest } from "#runtime/loaders/manifest.js";++// Some NFS and FUSE mounts reject hard links with Linux ENOTSUPP (524), which Node cannot name.+vi.mock("node:fs/promises", async (importOriginal) => ({+ ...(await importOriginal<typeof import("node:fs/promises")>()),+ link: async () => {+ throw Object.assign(new Error("Unknown system error -524"), { errno: -524, syscall: "link" });+ },+}));++const createAppRoot = useTemporaryAppRoots();++describe("loadCompiledModuleMapFromAuthoredSource", () => {+ it("loads mounted extensions on a filesystem without hard links", async () => {+ const app = await createAppRoot("eve-no-hard-links-", {+ files: {+ "agent/agent.mjs": 'export default { model: "openai/gpt-5.4" };',+ "agent/instructions.md": "Work with the available tools.",+ "agent/extensions/one.mjs": 'import ext from "@acme/crm"; export default ext;',+ "node_modules/@acme/crm/package.json": JSON.stringify({+ name: "@acme/crm",+ type: "module",+ eve: { extension: { source: "source", dist: "extension" } },+ exports: { ".": "./extension/extension.mjs" },+ }),+ "node_modules/@acme/crm/extension/_manifest.json": JSON.stringify({+ kind: "eve-extension",+ formatVersion: 1,+ builtWithEve: "0.0.0-test",+ requires: { extension: 1 },+ }),+ "node_modules/@acme/crm/extension/extension.mjs": 'export default { name: "crm" };',+ },+ });+ await compileAgent({ startPath: app.appRoot });+ const compiledArtifactsSource = createDiskRuntimeCompiledArtifactsSource(app.appRoot);+ const manifest = await loadCompiledManifest({ compiledArtifactsSource });++ const moduleMap = await loadCompiledModuleMapFromAuthoredSource({ compiledArtifactsSource });++ const mountSourceId = manifest.extensionMounts[0]!.mountSourceId;+ expect(moduleMap.nodes[ROOT_COMPILED_AGENT_NODE_ID]!.modules[mountSourceId]!.default).toEqual({+ name: "crm",+ });+ });+});diff --git a/packages/eve/src/internal/authored-module-map-loader.ts b/packages/eve/src/internal/authored-module-map-loader.tsindex c0d2b39e8..5ae5b279b 100644--- a/packages/eve/src/internal/authored-module-map-loader.ts+++ b/packages/eve/src/internal/authored-module-map-loader.ts@@ -1,5 +1,5 @@import { createHash, randomUUID } from "node:crypto";-import { link, mkdir, unlink, writeFile } from "node:fs/promises";+import { mkdir, unlink, writeFile } from "node:fs/promises";import { join, relative, resolve } from "node:path";import { pathToFileURL } from "node:url";@@ -25,6 +25,7 @@ import { readMaterializedAuthoredModuleIndex } from "#internal/materialized-authimport type { RuntimeDiskCompiledArtifactsSource } from "#runtime/compiled-artifacts-source.js";import { loadCompiledManifest } from "#runtime/loaders/manifest.js";import { formatValidationError } from "#runtime/validation.js";+import { renameWithTransientBusyRetry } from "#shared/rename-with-retry.js";/** Hydrates the compiled module map from the manifest’s authored bindings. */export async function loadCompiledModuleMapFromAuthoredSource(input: {@@ -74,11 +75,9 @@ async function hydrateCompiledModuleMapFromManifest(const temporaryPath = `${outputPath}.${randomUUID()}.tmp`;try {await writeFile(temporaryPath, code, { flag: "wx" });- try {- await link(temporaryPath, outputPath);- } catch (error) {- if ((error as NodeJS.ErrnoException).code !== "EEXIST") throw error;- }+ // Not link(): some NFS and FUSE mounts reject hard links. The name is the content hash,+ // so replacing a concurrent writer's file swaps identical bytes.+ await renameWithTransientBusyRetry(temporaryPath, outputPath);} finally {await unlink(temporaryPath).catch((error: NodeJS.ErrnoException) => {if (error.code !== "ENOENT") throw error;