Builds errors bugfix

This commit is contained in:
2026-10-16 16:54:55 +01:00
parent af12852fb9
commit 8a981c854a
8 changed files with 50 additions and 6 deletions
+3
View File
@@ -6,6 +6,7 @@ import bunextInit from "../../functions/bunext-init";
import type { BuildDataType } from "../../types";
import { v4 } from "uuid";
import { updatePageLastmodRecord } from "../../utils/page-lastmod-record";
import disposeBundlerContexts from "../../functions/bundler/dispose-bundler-contexts";
const {
HYDRATION_DST_DIR,
@@ -33,6 +34,8 @@ export default function () {
await bunextInit({ build_only: true });
await disposeBundlerContexts({ stop_service: true });
// A failed bundle must fail the command: CI and scripts rely on
// the exit code instead of grepping logs.
if (global.BUNEXT_BUILD_FAILED) {
@@ -1,9 +1,20 @@
import * as esbuild from "esbuild";
type Params = {
/**
* Also stop esbuild's service process. Only safe when no other esbuild
* call can be in flight (e.g. before exiting, or right after the startup
* build). The service restarts on the next esbuild call.
*/
stop_service?: boolean;
};
/**
* Disposes the hydration and SSR esbuild contexts, releasing the incremental
* build state esbuild keeps in memory for them. The bundlers re-create the
* contexts on their next run.
*/
export default async function disposeBundlerContexts() {
export default async function disposeBundlerContexts(params?: Params) {
try {
await global.BUNEXT_BUNDLER_CTX?.dispose();
} catch (error) {}
@@ -13,4 +24,13 @@ export default async function disposeBundlerContexts() {
await global.BUNEXT_SSR_BUNDLER_CTX?.dispose();
} catch (error) {}
global.BUNEXT_SSR_BUNDLER_CTX = undefined;
if (params?.stop_service) {
// Exiting while the service is still running can leave it orphaned
// with an unanswered ping, which crashes it with "all goroutines are
// asleep - deadlock!".
try {
await esbuild.stop();
} catch (error) {}
}
}
+1 -1
View File
@@ -165,7 +165,7 @@ export default async function bunextInit(params?: Params) {
await allPagesESBuildContextBundler({ start: true });
// The server only needs the artifact maps; don't keep
// esbuild's build state alive for the rest of the process.
await disposeBundlerContexts();
await disposeBundlerContexts({ stop_service: true });
}
cron();