Files
bunext/dist/functions/bundler/build-on-start-error-handler.js
T
2026-10-02 07:04:22 +01:00

18 lines
866 B
JavaScript

export default async function buildOnstartErrorHandler(params) {
if (global.BUNEXT_BUNDLER_CTX_DISPOSED) {
return;
}
global.BUNEXT_BUNDLER_CTX_DISPOSED = true;
global.BUNEXT_RECOMPILING = false;
global.BUNEXT_IS_SERVER_COMPONENT = false;
// NOTE: must NOT dispose the currently-building context here. This
// handler runs from the artifact-tracker plugin's onStart, i.e. while the
// context's own build is in flight. esbuild's `dispose()` waits for the
// in-flight build to finish, so disposing self = deadlock, which left the
// dev server permanently stuck after a failed rebuild.
//
// Marking the context as disposed is enough: the next rebuild attempt
// (watcher / fullRebuild) sees BUNEXT_BUNDLER_CTX_DISPOSED and recreates a
// fresh context, whose cleanup disposes the old (now idle) one.
}