Skip to content

@astrojs/node doesn't use experimental.logger #16974

Description

@Xiot

Astro Info

Astro                    v6.4.4
Vite                     v7.3.3
Node                     v24.14.0
System                   macOS (arm64)
Package Manager          yarn
Output                   server
Adapter                  @astrojs/node
Integrations             @astrojs/preact

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

I'm using the experimental json logging, however it appears that it isn't picked up by @astrojs/node, at least for the initial messages.

snippet of config

experimental: {
  logging: logHandlers.json()
}

I was able to work around this with a small patch to @astrojs/node that looks like this. (the diff was generated against @astrojs/node v10.1.1)

diff --git a/dist/server.js b/dist/server.js
index 2539053c66f2de662f5dbbfc816957e6b760b1c6..a1e4a2f94b425223a269c6515616e6f896ce2969 100644
--- a/dist/server.js
+++ b/dist/server.js
@@ -6,6 +6,8 @@ import { readHeadersJson } from "./shared.js";
 import _startServer, { createStandaloneHandler } from "./standalone.js";
 setGetEnv((key) => process.env[key]);
 const app = createApp({ streaming: !options.experimentalDisableStreaming });
+await app.pipeline.getLogger();
+app.resetAdapterLogger();
 const headersMap = options.staticHeaders ? readHeadersJson(app.manifest.outDir) : void 0;
 const handler = options.mode === "middleware" ? createMiddleware(app, options) : createStandaloneHandler(app, options, headersMap);
 const startServer = () => _startServer(app, options, headersMap);

What's the expected result?

The initial Server listening on... message is emitted using the json logger rather than the console one.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-wwagtt16?file=README.md

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions