astro 7.1.4 → 7.1.5

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.
@@ -1,6 +1,6 @@
1
1
  class BuildTimeAstroVersionProvider {
2
2
  // Injected during the build through esbuild define
3
- version = "7.1.4";
3
+ version = "7.1.5";
4
4
  }
5
5
  export {
6
6
  BuildTimeAstroVersionProvider
@@ -65,8 +65,7 @@ function createManifest(manifest, renderers, middleware) {
65
65
  debugInfoOutput: "",
66
66
  placement: void 0
67
67
  },
68
- logLevel: "silent",
69
- loggerConfig: manifest?.loggerConfig ?? void 0
68
+ logLevel: "silent"
70
69
  };
71
70
  }
72
71
  class experimental_AstroContainer {
@@ -196,7 +196,7 @@ ${contentConfig.error.message}`
196
196
  logger.info("Content config changed");
197
197
  shouldClear = true;
198
198
  }
199
- if (previousAstroVersion && previousAstroVersion !== "7.1.4") {
199
+ if (previousAstroVersion && previousAstroVersion !== "7.1.5") {
200
200
  logger.info("Astro version changed");
201
201
  shouldClear = true;
202
202
  }
@@ -204,8 +204,8 @@ ${contentConfig.error.message}`
204
204
  logger.info("Clearing content store");
205
205
  this.#store.clearAll();
206
206
  }
207
- if ("7.1.4") {
208
- this.#store.metaStore().set("astro-version", "7.1.4");
207
+ if ("7.1.5") {
208
+ this.#store.metaStore().set("astro-version", "7.1.5");
209
209
  }
210
210
  if (currentConfigDigest) {
211
211
  this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -12,7 +12,6 @@ import type { BaseSessionConfig, SessionDriverFactory } from '../session/types.j
12
12
  import type { DevToolbarPlacement } from '../../types/public/toolbar.js';
13
13
  import type { MiddlewareMode } from '../../types/public/integrations.js';
14
14
  import type { BaseApp } from './base.js';
15
- import type { LoggerHandlerConfig } from '../logger/config.js';
16
15
  type ComponentPath = string;
17
16
  export type StylesheetAsset = {
18
17
  type: 'inline';
@@ -138,7 +137,6 @@ export type SSRManifest = {
138
137
  };
139
138
  internalFetchHeaders?: Record<string, string>;
140
139
  logLevel: AstroLoggerLevel;
141
- loggerConfig: LoggerHandlerConfig | undefined;
142
140
  };
143
141
  export type SSRActions = {
144
142
  server: Record<string, ActionClient<any, any, any>>;
@@ -11,7 +11,6 @@ import { createDefaultRoutes } from "./routing/default.js";
11
11
  import { ensure404Route } from "./routing/astro-designed-error-pages.js";
12
12
  import { Router } from "./routing/router.js";
13
13
  import { FORBIDDEN_PATH_KEYS } from "@astrojs/internal-helpers/object";
14
- import { loadLoggerDestination } from "./logger/load.js";
15
14
  const PipelineFeatures = {
16
15
  redirects: 1 << 0,
17
16
  sessions: 1 << 1,
@@ -171,9 +170,10 @@ class Pipeline {
171
170
  return this.logger;
172
171
  }
173
172
  this.resolvedLogger = true;
174
- if (this.manifest.loggerConfig) {
173
+ const destination = (await this.manifest.logger?.())?.default;
174
+ if (destination) {
175
175
  this.logger = new AstroLogger({
176
- destination: await loadLoggerDestination(this.manifest.loggerConfig),
176
+ destination,
177
177
  level: this.manifest.logLevel
178
178
  });
179
179
  }
@@ -231,6 +231,12 @@ class Pipeline {
231
231
  );
232
232
  }
233
233
  for (const key of pathKeys) {
234
+ if (typeof server === "function") {
235
+ throw new AstroError({
236
+ ...ActionNotFoundError,
237
+ message: ActionNotFoundError.message(pathKeys.join("."))
238
+ });
239
+ }
234
240
  if (FORBIDDEN_PATH_KEYS.has(key)) {
235
241
  throw new AstroError({
236
242
  ...ActionNotFoundError,
@@ -236,10 +236,6 @@ async function buildManifest(opts, internals, staticFiles, encodedKey) {
236
236
  }
237
237
  }
238
238
  const middlewareMode = resolveMiddlewareMode(opts.settings.adapter?.adapterFeatures);
239
- let loggerConfig = void 0;
240
- if (settings.config.logger) {
241
- loggerConfig = settings.config.logger;
242
- }
243
239
  return {
244
240
  rootDir: opts.settings.config.root.toString(),
245
241
  cacheDir: opts.settings.config.cacheDir.toString(),
@@ -288,8 +284,7 @@ async function buildManifest(opts, internals, staticFiles, encodedKey) {
288
284
  },
289
285
  internalFetchHeaders,
290
286
  logLevel: settings.logLevel,
291
- shouldInjectCspMetaTags: shouldTrackCspHashes(settings.config.security.csp),
292
- loggerConfig
287
+ shouldInjectCspMetaTags: shouldTrackCspHashes(settings.config.security.csp)
293
288
  };
294
289
  }
295
290
  export {
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "7.1.4";
1
+ const ASTRO_VERSION = "7.1.5";
2
2
  const ASTRO_GENERATOR = `Astro v${ASTRO_VERSION}`;
3
3
  const ASTRO_ERROR_HEADER = "X-Astro-Error";
4
4
  const DEFAULT_404_COMPONENT = "astro-default-404.astro";
@@ -48,6 +48,7 @@ import { ServerIslandsState } from "./server-islands/shared-state.js";
48
48
  import { vitePluginServerIslands } from "./server-islands/vite-plugin-server-islands.js";
49
49
  import { vitePluginCacheProvider } from "./cache/vite-plugin.js";
50
50
  import { vitePluginSessionDriver } from "./session/vite-plugin.js";
51
+ import { vitePluginLogger } from "./logger/vite-plugin.js";
51
52
  import { isObject } from "./util-runtime.js";
52
53
  import { vitePluginEnvironment } from "../vite-plugin-environment/index.js";
53
54
  import { ASTRO_VITE_ENVIRONMENT_NAMES } from "./constants.js";
@@ -180,6 +181,7 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
180
181
  vitePluginServerIslands({ settings, logger, serverIslandsState }),
181
182
  vitePluginSessionDriver({ settings }),
182
183
  vitePluginCacheProvider({ settings }),
184
+ vitePluginLogger({ settings }),
183
185
  astroContainer(),
184
186
  astroHmrReloadPlugin(),
185
187
  vitePluginChromedevtools({ settings }),
@@ -26,7 +26,7 @@ async function dev(inlineConfig) {
26
26
  await telemetry.record([]);
27
27
  const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
28
28
  const logger = restart.container.logger;
29
- const currentVersion = "7.1.4";
29
+ const currentVersion = "7.1.5";
30
30
  const isPrerelease = currentVersion.includes("-");
31
31
  if (!isPrerelease) {
32
32
  try {
@@ -1,6 +1,6 @@
1
1
  import type { BaseApp, RenderErrorOptions } from '../app/base.js';
2
2
  import type { Pipeline } from '../base-pipeline.js';
3
- import type { ErrorHandler } from './handler.js';
3
+ import { type ErrorHandler } from './handler.js';
4
4
  /**
5
5
  * The default error handler used in production SSR. Attempts to render the
6
6
  * matching error route (404.astro / 500.astro), falling back to a plain
@@ -9,6 +9,7 @@ import { provideSession } from "../session/handler.js";
9
9
  import { validateHost } from "../app/validate-headers.js";
10
10
  import { getErrorRoutePath } from "../../i18n/error-routes.js";
11
11
  import { getOutputFilename } from "../output-filename.js";
12
+ import { rewroteToEmptyErrorResponse } from "./handler.js";
12
13
  class DefaultErrorHandler {
13
14
  #app;
14
15
  #astroMiddleware;
@@ -82,6 +83,21 @@ class DefaultErrorHandler {
82
83
  errorState,
83
84
  this.#pagesHandler.handle.bind(this.#pagesHandler)
84
85
  );
86
+ if (rewroteToEmptyErrorResponse(
87
+ skipMiddleware,
88
+ errorRouteData,
89
+ errorState.routeData,
90
+ response2
91
+ )) {
92
+ return this.renderError(request, {
93
+ ...resolvedRenderOptions,
94
+ status,
95
+ error,
96
+ response: originalResponse,
97
+ skipMiddleware: true,
98
+ pathname: resolvedPathname
99
+ });
100
+ }
85
101
  const newResponse = mergeResponses(response2, originalResponse);
86
102
  prepareResponse(newResponse, resolvedRenderOptions);
87
103
  return newResponse;
@@ -1,6 +1,6 @@
1
1
  import type { BaseApp, RenderErrorOptions } from '../app/base.js';
2
2
  import type { Pipeline } from '../base-pipeline.js';
3
- import type { ErrorHandler } from './handler.js';
3
+ import { type ErrorHandler } from './handler.js';
4
4
  export interface DevErrorHandlerOptions {
5
5
  /**
6
6
  * Whether to inject CSP meta tags into the rendered error page response.
@@ -4,6 +4,7 @@ import { PagesHandler } from "../pages/handler.js";
4
4
  import { getCustom404Route, getCustom500Route } from "../routing/helpers.js";
5
5
  import { isAstroError } from "./index.js";
6
6
  import { MiddlewareNoDataOrNextCalled, MiddlewareNotAResponse } from "./errors-data.js";
7
+ import { rewroteToEmptyErrorResponse } from "./handler.js";
7
8
  class DevErrorHandler {
8
9
  #app;
9
10
  #shouldInjectCspMetaTags;
@@ -46,6 +47,15 @@ class DevErrorHandler {
46
47
  errorState,
47
48
  this.#pagesHandler.handle.bind(this.#pagesHandler)
48
49
  );
50
+ if (rewroteToEmptyErrorResponse(skipMiddleware, routeData, errorState.routeData, response)) {
51
+ return this.renderError(request, {
52
+ ...resolvedRenderOptions,
53
+ status,
54
+ error,
55
+ skipMiddleware: true,
56
+ pathname: resolvedPathname
57
+ });
58
+ }
49
59
  if (error) {
50
60
  app.logger.error("router", error.stack || error.message);
51
61
  }
@@ -1,4 +1,5 @@
1
1
  import type { RenderErrorOptions } from '../app/base.js';
2
+ import type { RouteData } from '../../types/public/index.js';
2
3
  /**
3
4
  * A strategy for rendering error responses (404, 500, etc.). Each execution
4
5
  * environment (prod SSR, build/prerender, dev server) supplies its own
@@ -7,3 +8,16 @@ import type { RenderErrorOptions } from '../app/base.js';
7
8
  export interface ErrorHandler {
8
9
  renderError(request: Request, options: RenderErrorOptions): Promise<Response>;
9
10
  }
11
+ /**
12
+ * Whether a middleware rewrite (`ctx.rewrite()` / `next(payload)`) issued while
13
+ * rendering the error page dead-ended in another empty reroutable (404/500)
14
+ * response. The rewrite swaps the state's routeData away from the error route,
15
+ * so returning that render as-is would produce a blank page; the error handler
16
+ * should instead retry rendering the error page without middleware.
17
+ *
18
+ * @param skipMiddleware Whether middleware was already skipped for this render.
19
+ * @param errorRouteData The error route matched before middleware ran.
20
+ * @param renderedRouteData The route data on the state after middleware ran.
21
+ * @param response The response produced by the middleware-driven render.
22
+ */
23
+ export declare function rewroteToEmptyErrorResponse(skipMiddleware: boolean, errorRouteData: RouteData, renderedRouteData: RouteData | undefined, response: Response): boolean;
@@ -0,0 +1,7 @@
1
+ import { REROUTABLE_STATUS_CODES } from "../constants.js";
2
+ function rewroteToEmptyErrorResponse(skipMiddleware, errorRouteData, renderedRouteData, response) {
3
+ return skipMiddleware === false && renderedRouteData !== errorRouteData && response.body === null && REROUTABLE_STATUS_CODES.includes(response.status);
4
+ }
5
+ export {
6
+ rewroteToEmptyErrorResponse
7
+ };
@@ -1,6 +1,10 @@
1
1
  import { AstroLogger, type AstroLoggerDestination } from './core.js';
2
2
  import type { LoggerHandlerConfig } from './config.js';
3
3
  import type { AstroConfig, AstroInlineConfig } from '../../types/public/index.js';
4
+ /**
5
+ * Loads a logger destination in a Node context, i.e. outside of a built server bundle.
6
+ * Inside the bundle, the destination comes from the `virtual:astro:logger` module instead.
7
+ */
4
8
  export declare function loadLoggerDestination(config: LoggerHandlerConfig): Promise<AstroLoggerDestination>;
5
9
  /**
6
10
  * It attempts to load a logger from the entrypoint.
@@ -1,64 +1,38 @@
1
+ import { isAbsolute } from "node:path";
2
+ import { pathToFileURL } from "node:url";
1
3
  import { AstroLogger } from "./core.js";
2
4
  import { AstroError } from "../errors/index.js";
3
5
  import { UnableToLoadLogger } from "../errors/errors-data.js";
4
- import { default as nodeLoggerCreator, createNodeLoggerFromFlags } from "./impls/node.js";
5
- import { default as consoleLoggerCreator } from "./impls/console.js";
6
- import { default as jsonLoggerCreator } from "./impls/json.js";
7
- import { default as composeLoggerCreator } from "./impls/compose.js";
8
- function normalizeEntrypoint(entrypoint) {
9
- return entrypoint instanceof URL ? entrypoint.href : entrypoint;
6
+ import { createNodeLoggerFromFlags } from "./impls/node.js";
7
+ import {
8
+ COMPOSE_LOGGER_ENTRYPOINT,
9
+ normalizeLoggerConfig
10
+ } from "./utils.js";
11
+ async function createDestination(config) {
12
+ const specifier = isAbsolute(config.entrypoint) ? pathToFileURL(config.entrypoint).href : config.entrypoint;
13
+ const logger = await import(
14
+ /* @vite-ignore */
15
+ specifier
16
+ );
17
+ if (config.entrypoint === COMPOSE_LOGGER_ENTRYPOINT) {
18
+ return logger.default(await Promise.all((config.loggers ?? []).map(createDestination)));
19
+ }
20
+ return logger.default(config.config);
10
21
  }
11
22
  async function loadLoggerDestination(config) {
12
- let cause = void 0;
13
- const entrypoint = normalizeEntrypoint(config.entrypoint);
23
+ const normalized = normalizeLoggerConfig(config);
14
24
  try {
15
- switch (config.entrypoint) {
16
- case "astro/logger/node": {
17
- return nodeLoggerCreator(config.config);
18
- }
19
- case "astro/logger/console": {
20
- return consoleLoggerCreator(config.config);
21
- }
22
- case "astro/logger/json": {
23
- return jsonLoggerCreator(config.config);
24
- }
25
- case "astro/logger/compose": {
26
- let destinations = [];
27
- if (config.config?.loggers) {
28
- const loggers = config.config?.loggers;
29
- destinations = await Promise.all(
30
- loggers.map(async (loggerConfig) => {
31
- const logger = await import(
32
- /* @vite-ignore */
33
- normalizeEntrypoint(loggerConfig.entrypoint)
34
- );
35
- return logger.default(loggerConfig.config);
36
- })
37
- );
38
- }
39
- return composeLoggerCreator(destinations);
40
- }
41
- default: {
42
- const logger = await import(
43
- /* @vite-ignore */
44
- entrypoint
45
- );
46
- return logger.default(config.config);
47
- }
48
- }
25
+ return await createDestination(normalized);
49
26
  } catch (e) {
27
+ const error = new AstroError({
28
+ ...UnableToLoadLogger,
29
+ message: UnableToLoadLogger.message(normalized.entrypoint)
30
+ });
50
31
  if (e instanceof Error) {
51
- cause = e;
32
+ error.cause = e;
52
33
  }
34
+ throw error;
53
35
  }
54
- const error = new AstroError({
55
- ...UnableToLoadLogger,
56
- message: UnableToLoadLogger.message(entrypoint)
57
- });
58
- if (cause) {
59
- error.cause = cause;
60
- }
61
- throw error;
62
36
  }
63
37
  async function loadOrCreateNodeLogger(astroConfig, inlineAstroConfig) {
64
38
  if (inlineAstroConfig._logger) return inlineAstroConfig._logger;
@@ -0,0 +1,21 @@
1
+ import type { LoggerHandlerConfig } from './config.js';
2
+ export declare const COMPOSE_LOGGER_ENTRYPOINT = "astro/logger/compose";
3
+ export interface NormalizedLoggerConfig {
4
+ /** An absolute file path or a package specifier */
5
+ entrypoint: string;
6
+ /** Serializable options passed to the handler factory */
7
+ config?: Record<string, any> | undefined;
8
+ /** The composed handlers. Only set for `astro/logger/compose` */
9
+ loggers?: NormalizedLoggerConfig[];
10
+ }
11
+ /**
12
+ * Normalizes a user-provided logger config by turning its `entrypoint` into a string that
13
+ * can be resolved as-is, either by Vite (see `vitePluginLogger`) or by Node
14
+ * (see `loadLoggerDestination`), and by applying the same treatment to the handlers
15
+ * composed through `astro/logger/compose`.
16
+ *
17
+ * Concretely, a `URL` entrypoint becomes an absolute file path — mirroring what session
18
+ * drivers do, since both Vite and `import()` can handle those — while a string entrypoint,
19
+ * e.g. a package specifier, is left untouched.
20
+ */
21
+ export declare function normalizeLoggerConfig(logger: LoggerHandlerConfig): NormalizedLoggerConfig;
@@ -0,0 +1,20 @@
1
+ import { fileURLToPath } from "node:url";
2
+ const COMPOSE_LOGGER_ENTRYPOINT = "astro/logger/compose";
3
+ function normalizeLoggerConfig(logger) {
4
+ const entrypoint = normalizeEntrypoint(logger.entrypoint);
5
+ if (entrypoint === COMPOSE_LOGGER_ENTRYPOINT) {
6
+ const loggers = logger.config?.loggers ?? [];
7
+ return {
8
+ entrypoint,
9
+ loggers: loggers.map((nested) => normalizeLoggerConfig(nested))
10
+ };
11
+ }
12
+ return { entrypoint, config: logger.config };
13
+ }
14
+ function normalizeEntrypoint(entrypoint) {
15
+ return entrypoint instanceof URL ? fileURLToPath(entrypoint) : entrypoint;
16
+ }
17
+ export {
18
+ COMPOSE_LOGGER_ENTRYPOINT,
19
+ normalizeLoggerConfig
20
+ };
@@ -0,0 +1,30 @@
1
+ import type { Plugin as VitePlugin } from 'vite';
2
+ import type { AstroSettings } from '../../types/astro.js';
3
+ import { type NormalizedLoggerConfig } from './utils.js';
4
+ export declare const VIRTUAL_LOGGER_ID = "virtual:astro:logger";
5
+ /** Resolves an entrypoint to a module id, or `null` if it cannot be resolved. */
6
+ type ResolveEntrypoint = (entrypoint: string) => Promise<string | null>;
7
+ interface EmittedDestination {
8
+ /** The expression instantiating the destination, e.g. `_logger0({ level: 'info' })` */
9
+ expression: string;
10
+ /** The import statements `expression` depends on, in declaration order */
11
+ imports: string[];
12
+ }
13
+ /**
14
+ * Emits the source of a logger destination, so that the handler is part of the bundle
15
+ * rather than imported at runtime from a path that no longer exists once deployed.
16
+ *
17
+ * This is the build-time counterpart of `createDestination()` in `./load.ts`: both walk
18
+ * the same normalized config, but this one *generates code* that instantiates the
19
+ * destination, while the Node one instantiates it directly through `import()`.
20
+ */
21
+ export declare function emitDestination(config: NormalizedLoggerConfig, resolveEntrypoint: ResolveEntrypoint,
22
+ /**
23
+ * Import names must be unique across the whole virtual module, so nested
24
+ * destinations continue numbering where their parent left off.
25
+ */
26
+ nameOffset?: number): Promise<EmittedDestination>;
27
+ export declare function vitePluginLogger({ settings, }: {
28
+ settings: AstroSettings;
29
+ }): VitePlugin | undefined;
30
+ export {};
@@ -0,0 +1,79 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import { UnableToLoadLogger } from "../errors/errors-data.js";
3
+ import { AstroError } from "../errors/index.js";
4
+ import { normalizeLoggerConfig } from "./utils.js";
5
+ const VIRTUAL_LOGGER_ID = "virtual:astro:logger";
6
+ const RESOLVED_VIRTUAL_LOGGER_ID = "\0" + VIRTUAL_LOGGER_ID;
7
+ async function emitDestination(config, resolveEntrypoint, nameOffset = 0) {
8
+ let resolved = null;
9
+ let cause;
10
+ try {
11
+ resolved = await resolveEntrypoint(config.entrypoint);
12
+ } catch (e) {
13
+ cause = e;
14
+ }
15
+ if (!resolved) {
16
+ const error = new AstroError({
17
+ ...UnableToLoadLogger,
18
+ message: UnableToLoadLogger.message(config.entrypoint)
19
+ });
20
+ if (cause instanceof Error) {
21
+ error.cause = cause;
22
+ }
23
+ throw error;
24
+ }
25
+ const name = `_logger${nameOffset}`;
26
+ const imports = [`import ${name} from ${JSON.stringify(resolved)};`];
27
+ if (config.loggers) {
28
+ const expressions = [];
29
+ for (const nested of config.loggers) {
30
+ const emitted = await emitDestination(nested, resolveEntrypoint, nameOffset + imports.length);
31
+ imports.push(...emitted.imports);
32
+ expressions.push(emitted.expression);
33
+ }
34
+ return { expression: `${name}([${expressions.join(", ")}])`, imports };
35
+ }
36
+ return { expression: `${name}(${JSON.stringify(config.config) ?? "undefined"})`, imports };
37
+ }
38
+ function vitePluginLogger({
39
+ settings
40
+ }) {
41
+ const loggerConfig = settings.config.logger;
42
+ if (!loggerConfig) {
43
+ return;
44
+ }
45
+ return {
46
+ name: VIRTUAL_LOGGER_ID,
47
+ enforce: "pre",
48
+ resolveId: {
49
+ filter: {
50
+ id: new RegExp(`^${VIRTUAL_LOGGER_ID}$`)
51
+ },
52
+ handler() {
53
+ return RESOLVED_VIRTUAL_LOGGER_ID;
54
+ }
55
+ },
56
+ load: {
57
+ filter: {
58
+ id: new RegExp(`^${RESOLVED_VIRTUAL_LOGGER_ID}$`)
59
+ },
60
+ async handler() {
61
+ const importerPath = fileURLToPath(new URL("package.json", settings.config.root));
62
+ const { expression, imports } = await emitDestination(
63
+ normalizeLoggerConfig(loggerConfig),
64
+ async (entrypoint) => (await this.resolve(entrypoint, importerPath))?.id ?? null
65
+ );
66
+ return {
67
+ code: `${imports.join("\n")}
68
+ export default ${expression};
69
+ `
70
+ };
71
+ }
72
+ }
73
+ };
74
+ }
75
+ export {
76
+ VIRTUAL_LOGGER_ID,
77
+ emitDestination,
78
+ vitePluginLogger
79
+ };
@@ -270,7 +270,7 @@ function printHelp({
270
270
  message.push(
271
271
  linebreak(),
272
272
  ` ${bgGreen(black(` ${commandName} `))} ${green(
273
- `v${"7.1.4"}`
273
+ `v${"7.1.5"}`
274
274
  )} ${headline}`
275
275
  );
276
276
  }
@@ -93,6 +93,7 @@ class AstroHandler {
93
93
  const defaultStatus = this.#app.getDefaultStatusCode(routeData, pathname);
94
94
  state.status = defaultStatus;
95
95
  let response;
96
+ let finalizeError;
96
97
  try {
97
98
  const sessionP = this.#hasSession ? provideSession(state) : void 0;
98
99
  const cacheP = provideCache(state);
@@ -143,8 +144,21 @@ class AstroHandler {
143
144
  pathname: state.pathname
144
145
  });
145
146
  } finally {
146
- const finalize = state.finalizeAll();
147
- if (finalize) await finalize;
147
+ try {
148
+ const finalize = state.finalizeAll();
149
+ if (finalize) await finalize;
150
+ } catch (err) {
151
+ finalizeError = err;
152
+ this.#app.logger.error(null, err.stack || err.message || String(err));
153
+ }
154
+ }
155
+ if (finalizeError) {
156
+ return this.#app.renderError(request, {
157
+ ...state.renderOptions,
158
+ status: 500,
159
+ error: finalizeError,
160
+ pathname: state.pathname
161
+ });
148
162
  }
149
163
  if (REROUTABLE_STATUS_CODES.includes(response.status) && // If the body isn't null, that means the user sets the 404 status
150
164
  // but uses the current route to handle the 404
@@ -20,6 +20,7 @@ import { MIDDLEWARE_MODULE_ID } from "../core/middleware/vite-plugin.js";
20
20
  import { SERVER_ISLAND_MANIFEST } from "../core/server-islands/vite-plugin-server-islands.js";
21
21
  import { VIRTUAL_CACHE_PROVIDER_ID } from "../core/cache/vite-plugin.js";
22
22
  import { VIRTUAL_SESSION_DRIVER_ID } from "../core/session/vite-plugin.js";
23
+ import { VIRTUAL_LOGGER_ID } from "../core/logger/vite-plugin.js";
23
24
  import { VIRTUAL_PAGES_MODULE_ID } from "../vite-plugin-pages/index.js";
24
25
  import { ASTRO_RENDERERS_MODULE_ID } from "../vite-plugin-renderers/index.js";
25
26
  import { ASTRO_ROUTES_MODULE_ID } from "../vite-plugin-routes/index.js";
@@ -86,6 +87,7 @@ function serializedManifestPlugin({
86
87
  }
87
88
  const hasCacheConfig = !!settings.config.cache?.provider;
88
89
  const cacheProviderLine = hasCacheConfig ? `cacheProvider: () => import('${VIRTUAL_CACHE_PROVIDER_ID}'),` : "";
90
+ const loggerLine = settings.config.logger ? `logger: () => import('${VIRTUAL_LOGGER_ID}'),` : "";
89
91
  const code = `
90
92
  import { deserializeManifest as _deserializeManifest } from 'astro/app';
91
93
  import { renderers } from '${ASTRO_RENDERERS_MODULE_ID}';
@@ -106,6 +108,7 @@ function serializedManifestPlugin({
106
108
  middleware: () => import('${MIDDLEWARE_MODULE_ID}'),
107
109
  sessionDriver: () => import('${VIRTUAL_SESSION_DRIVER_ID}'),
108
110
  ${cacheProviderLine}
111
+ ${loggerLine}
109
112
  serverIslandMappings: () => import('${SERVER_ISLAND_MANIFEST}'),
110
113
  routes: manifestRoutes,
111
114
  pageMap,
@@ -157,10 +160,6 @@ async function createSerializedManifest(settings, encodedKey) {
157
160
  styleDirective
158
161
  };
159
162
  }
160
- let loggerConfig = void 0;
161
- if (settings.config.logger) {
162
- loggerConfig = settings.config.logger;
163
- }
164
163
  return {
165
164
  rootDir: settings.config.root.toString(),
166
165
  srcDir: settings.config.srcDir.toString(),
@@ -210,8 +209,7 @@ async function createSerializedManifest(settings, encodedKey) {
210
209
  placement: settings.config.devToolbar.placement
211
210
  },
212
211
  logLevel: settings.logLevel,
213
- shouldInjectCspMetaTags: false,
214
- loggerConfig
212
+ shouldInjectCspMetaTags: false
215
213
  };
216
214
  }
217
215
  export {
@@ -1516,8 +1516,7 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1516
1516
  *
1517
1517
  * By default, Astro uses a built-in logger that outputs human-friendly logs to the console. You can customize this behavior by providing [your own logger handler](https://docs.astro.build/en/reference/logger-reference/#custom-loggers) or by using one of the [built-in log handlers](https://docs.astro.build/en/reference/logger-reference/#built-in-loggers):
1518
1518
  *
1519
- * ```js
1520
- * // astro.config.mjs
1519
+ * ```js title="astro.config.mjs"
1521
1520
  * import { defineConfig, logHandlers } from 'astro/config';
1522
1521
  *
1523
1522
  * export default defineConfig({
@@ -1535,7 +1534,8 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1535
1534
  * @version 7.0.0
1536
1535
  * @description
1537
1536
  *
1538
- * The entrypoint of the log handler. This can be a path to a file in your project or an npm package:
1537
+ * The entrypoint for the [logger implementation](https://docs.astro.build/en/reference/logger-reference/#the-logger-implementation).
1538
+ * This can be an npm package, or a `URL` pointing to a file in your project:
1539
1539
  *
1540
1540
  * ```js title="astro.config.mjs"
1541
1541
  * import { defineConfig } from 'astro/config';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "7.1.4",
3
+ "version": "7.1.5",
4
4
  "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
5
5
  "type": "module",
6
6
  "author": "withastro",
@@ -119,7 +119,7 @@
119
119
  "github-slugger": "^2.0.0",
120
120
  "html-escaper": "3.0.3",
121
121
  "http-cache-semantics": "^4.2.0",
122
- "js-yaml": "^4.1.1",
122
+ "js-yaml": "^4.3.0",
123
123
  "jsonc-parser": "^3.3.1",
124
124
  "magic-string": "^1.0.0",
125
125
  "magicast": "^0.5.2",
@@ -146,15 +146,15 @@
146
146
  "xxhash-wasm": "^1.1.0",
147
147
  "yargs-parser": "^22.0.0",
148
148
  "zod": "^4.3.6",
149
- "@astrojs/internal-helpers": "0.10.1",
150
- "@astrojs/markdown-satteri": "0.3.4",
149
+ "@astrojs/internal-helpers": "0.10.2",
150
+ "@astrojs/markdown-satteri": "0.3.5",
151
151
  "@astrojs/telemetry": "3.3.3"
152
152
  },
153
153
  "optionalDependencies": {
154
154
  "sharp": "^0.34.0 || ^0.35.0"
155
155
  },
156
156
  "peerDependencies": {
157
- "@astrojs/markdown-remark": "7.2.1"
157
+ "@astrojs/markdown-remark": "7.2.2"
158
158
  },
159
159
  "peerDependenciesMeta": {
160
160
  "@astrojs/markdown-remark": {
@@ -187,7 +187,7 @@
187
187
  "undici": "^7.22.0",
188
188
  "vitest": "^4.1.0",
189
189
  "@astrojs/check": "0.9.10",
190
- "@astrojs/markdown-remark": "7.2.1",
190
+ "@astrojs/markdown-remark": "7.2.2",
191
191
  "astro-scripts": "0.0.14"
192
192
  },
193
193
  "engines": {