From 4c922646bc80d9a0dc7a721156c1d8b165c8f3e8 Mon Sep 17 00:00:00 2001 From: Chris Barber Date: Fri, 1 May 2026 16:35:27 -0500 Subject: [PATCH 1/3] Use Harper readonly mode for Next.js builds --- src/plugin.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugin.ts b/src/plugin.ts index 109b39b..d51fbdc 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -270,6 +270,10 @@ async function build(scope: Scope, config: NextPluginConfig, next: NextPackage) scope.logger.debug?.(`Building Next.js application at ${scope.directory}`); + // Next.js generates static pages using child processes and only a single process can open the + // RocksDB databases, so force Harper to start in read-only mode + process.env.READONLY = 'true'; + // --expose-internals is set in Harper's worker execArgv but is not allowed in NODE_OPTIONS. // Next.js reads process.execArgv to forward flags to its own child workers via NODE_OPTIONS, // which causes Node to reject the build worker. Strip it before building and restore after. From c06a2ba945aa854f784b13963e534a08db5533b3 Mon Sep 17 00:00:00 2001 From: Chris Barber Date: Mon, 4 May 2026 15:02:46 -0500 Subject: [PATCH 2/3] Use update readonly env var --- src/plugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin.ts b/src/plugin.ts index d51fbdc..612f9f0 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -272,7 +272,7 @@ async function build(scope: Scope, config: NextPluginConfig, next: NextPackage) // Next.js generates static pages using child processes and only a single process can open the // RocksDB databases, so force Harper to start in read-only mode - process.env.READONLY = 'true'; + process.env.HARPER_READONLY = 'true'; // --expose-internals is set in Harper's worker execArgv but is not allowed in NODE_OPTIONS. // Next.js reads process.execArgv to forward flags to its own child workers via NODE_OPTIONS, From 1db85d7bf3a73dde8dfdf84371356f5b85671619 Mon Sep 17 00:00:00 2001 From: Chris Barber Date: Mon, 4 May 2026 17:24:45 -0500 Subject: [PATCH 3/3] Use new HARPER_READONLY env var, flush databases --- src/plugin.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugin.ts b/src/plugin.ts index 612f9f0..9529aea 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -1,4 +1,4 @@ -import type { Scope, Config, FilesOption } from 'harper'; +import { flushDatabases, type Scope, type Config, type FilesOption } from 'harper'; import { createRequire } from 'node:module'; import { parse as urlParse } from 'node:url'; @@ -273,6 +273,7 @@ async function build(scope: Scope, config: NextPluginConfig, next: NextPackage) // Next.js generates static pages using child processes and only a single process can open the // RocksDB databases, so force Harper to start in read-only mode process.env.HARPER_READONLY = 'true'; + await flushDatabases(); // --expose-internals is set in Harper's worker execArgv but is not allowed in NODE_OPTIONS. // Next.js reads process.execArgv to forward flags to its own child workers via NODE_OPTIONS,