Skip to content

Prerendering does not work when building Docker container #6275

Open
ntatoud/noe.tatoud.com
#131

Description

@NormySan

Which project does this relate to?

Start

Describe the bug

When trying to build a TanStack Start project in SPA mode with Docker Vite fails to connect to the server. The build works fine outside of Docker.

3.276 [nitro] ✔ You can preview this build using bun run .output/server/index.mjs
3.277 [prerender] Prerendering pages...
3.305
3.305  ╭───────────────── [Build Info] ────────────────────╮
3.305  │                                                   │
3.305  │  - Build Directory: .output                       │
3.305  │  - Date: 1/2/2026, 5:55:52 AM                     │
3.305  │  - Nitro Version: 3.0.1-20251230-165713-6e801e22  │
3.305  │  - Nitro Preset: bun                              │
3.305  │                                                   │
3.305  ╰───────────────────────────────────────────────────╯
3.305
3.305 ℹ Spawning preview server...
3.305 ℹ bun run ./server/index.mjs
3.305
3.324 ➜ Listening on: http://localhost:46317/ (all interfaces)
3.841 [prerender] Concurrency: 10
3.842 [prerender] Crawling: /
3.855 [prerender] Prerendered 0 pages:
3.859 error: Unable to connect. Is the computer able to access the url?
3.859   path: "http://localhost:3000/",
3.859  errno: 0,
3.859   code: "ConnectionRefused"

I've also tried forcing the Nitro port to run at 3000 which ends up with the Vite prerender server failing to start instead.

Your Example Website or App

https://github.com/NormySan/tanstack-start-spa-nitro

Steps to Reproduce the Bug or Issue

  1. Download repository
  2. Build the docker image with docker build -t tanstack-start/nitro .

Expected behavior

I expect it to be able to connect to the server and to the pre-rendering.

Screenshots or Videos

No response

Platform

  • Router / Start Version: Router 1.132.0 and Start 1.132.0
  • Nitro: Nightly at latest
  • Runtime: Bun
  • OS: Mac OS
  • Bundler: Vite
  • Bundler Version: 7.1.7

Additional context

Similar to the following issue:
#5967 (comment)

Activity

  1. schiller-manuel commented on Jan 2, 2026

    @schiller-manuel
    Collaborator

    does this work if not using nitro (just comment the plugin out) ? or does prerendering not work in general in docker?

  2. NormySan commented on Jan 2, 2026

    @NormySan
    Author

    I just tried commenting out the Nitro Vite plugin and build again and that doesn't work either. I'm guessing that nitro is needed for the pre-rendering since it doesn't even start a server for the pre-renderer to visit when Nitro is not being used.

    1.927 rendering chunks...
    1.931 dist/server/assets/start-HYkvq4Ni.js                        0.06 kB
    1.931 dist/server/assets/start.api-request-DhPN1_Dc.js            1.18 kB
    1.931 dist/server/assets/demo.punk-songs-DMWh_nLf.js              1.20 kB
    1.931 dist/server/assets/_tanstack-start-manifest_v-DVDDF2Vd.js   1.57 kB
    1.931 dist/server/assets/start.server-funcs-DBayRK6n.js           1.60 kB
    1.931 dist/server/assets/start.ssr.full-ssr-CNpWBhNP.js           1.62 kB
    1.931 dist/server/assets/start.ssr.data-only-DK82-T8R.js          1.62 kB
    1.931 dist/server/assets/start.ssr.spa-mode-B2Qcd2xk.js           1.73 kB
    1.931 dist/server/assets/start.ssr.index-BmCCCK3g.js              1.96 kB
    1.931 dist/server/assets/start.server-funcs-CnhSDiOa.js           2.74 kB
    1.931 dist/server/assets/index-Bn-KsgDK.js                        4.73 kB
    1.931 dist/server/assets/router-D0WcTyyP.js                      13.26 kB
    1.931 dist/server/server.js                                      41.01 kB
    1.931 ✓ built in 125ms
    1.931 [prerender] Prerendering pages...
    1.964 [prerender] Concurrency: 10
    1.964 [prerender] Crawling: /
    1.968 [prerender] Prerendered 0 pages:
    1.968 error: Unable to connect. Is the computer able to access the url?
    1.968   path: "http://localhost:45913/",
    1.968  errno: 0,
    1.968   code: "ConnectionRefused"
    1.968
    1.968
    1.968 Bun v1.3.5 (Linux arm64)
    1.980 error: script "build" exited with code 1
    
  3. schiller-manuel commented on Jan 2, 2026

    @schiller-manuel
    Collaborator

    nitro is not needed for prerendering. so most likely the vite preview server that is used for prerendering is not accessible in the docker env

    cc @edmundhung

  4. edmundhung commented on Jan 5, 2026

    @edmundhung
    Contributor

    #6305 should fix it.

    In the meantime, you can workaround it by removing the nitro plugin and set preview.host to true:

    const config = defineConfig({
    +  preview: {
    +    host: true,
    +  },
      plugins: [
        devtools(),
    -   nitro({ preset: "bun" }),

    The docker build is still falling with COPY --from=build /app/apps/web/.output . but it seems unrelated and bun run build step is already passed.

  5. isc30 commented on Feb 3, 2026

    @isc30

    Even after following these steps trying to get sitemap working, the sitemap.xml is not available in .output/server/sitemap.xml and only in .output/public/sitemap.xml. This means that node .output/server/index.mjs is not serving it on /sitemap.xml.

    Using

    preview: {
      host: true,
    },
    plugins: [
      nitro({ preset: 'node-server' }),
      // ...

    also tried running this after npm run build but doesnt work as the assets are explicitly listed in the server.mjs output:

    COPY .output/public/sitemap.xml .output/server/sitemap.xml
  6. edmundhung commented on Feb 3, 2026

    @edmundhung
    Contributor

    @isc30 Does that work if you remove the nitro plugin? Are you building it in a docker container too?

  7. isc30 commented on Feb 3, 2026

    @isc30

    doesn't work outside of docker either.

    without the nitro plugin im not sure how to run the server, as it returns 0 instantly

  8. xonio-x commented on Feb 3, 2026

    @xonio-x

    I try to remove the nitro plugin, and set the preview host, and for the bun user you can copy the server.ts from bun starter and it just work in dockerfile you guys just need to copy the dist folder, node modules and the server.ts

    But hopefully someone able to make it work with nitro 🥲I don't link copy the node modules 😅

  9. isc30 commented on Feb 3, 2026

    @isc30

    Hey @xonio-x how do you run the server without nitro?
    I get a dist folder and then try to run with node ./dist/server/server.js, which does nothing.

  10. conioX commented on Feb 4, 2026

    @conioX

    i use server.ts from the bun and i use runtime bun not node js so i dont know it possible with the node js @isc30

  11. conioX commented on Feb 4, 2026

    @conioX

    you can follow this node js based but require hono, and follow this readme.md file https://github.com/TanStack/router/tree/main/examples/react/start-bun this should work without nitro @isc30

    /**
     * TanStack Start Production Server with Node.js
     *
     * A high-performance production server for TanStack Start applications that
     * implements intelligent static asset loading with configurable memory management.
     *
     * Features:
     * - Hybrid loading strategy (preload small files, serve large files on-demand)
     * - Configurable file filtering with include/exclude patterns
     * - Memory-efficient response generation
     * - Production-ready caching headers
     * - ETag support for cache validation
     * - Gzip compression for eligible assets
     *
     * Environment Variables:
     *
     * PORT (number)
     *   - Server port number
     *   - Default: 3000
     *
     * ASSET_PRELOAD_MAX_SIZE (number)
     *   - Maximum file size in bytes to preload into memory
     *   - Files larger than this will be served on-demand from disk
     *   - Default: 5242880 (5MB)
     *
     * ASSET_PRELOAD_INCLUDE_PATTERNS (string)
     *   - Comma-separated list of glob patterns for files to include
     *   - Example: "*.js,*.css,*.woff2"
     *
     * ASSET_PRELOAD_EXCLUDE_PATTERNS (string)
     *   - Comma-separated list of glob patterns for files to exclude
     *   - Example: "*.map,*.txt"
     *
     * ASSET_PRELOAD_VERBOSE_LOGGING (boolean)
     *   - Enable detailed logging of loaded and skipped files
     *   - Default: false
     *
     * ASSET_PRELOAD_ENABLE_ETAG (boolean)
     *   - Enable ETag generation for preloaded assets
     *   - Default: true
     *
     * ASSET_PRELOAD_ENABLE_GZIP (boolean)
     *   - Enable Gzip compression for eligible assets
     *   - Default: true
     *
     * ASSET_PRELOAD_GZIP_MIN_SIZE (number)
     *   - Minimum file size in bytes required for Gzip compression
     *   - Default: 1024 (1KB)
     *
     * ASSET_PRELOAD_GZIP_MIME_TYPES (string)
     *   - Comma-separated list of MIME types eligible for Gzip compression
     *   - Default: text/,application/javascript,application/json,application/xml,image/svg+xml
     *
     * Usage:
     *   node --import tsx server.ts
     */
    
    import { serve } from "@hono/node-server";
    import { Hono, Context } from "hono";
    import { createReadStream } from "node:fs";
    import { readFile, stat } from "node:fs/promises";
    import { createHash } from "node:crypto";
    import { gzipSync } from "node:zlib";
    import { glob } from "glob";
    import { lookup } from "mime-types";
    import path from "node:path";
    
    // Configuration
    const SERVER_PORT = Number(process.env.PORT ?? 3000);
    const CLIENT_DIRECTORY = "./dist/client";
    const SERVER_ENTRY_POINT = "./dist/server/server.js";
    
    // Logging utilities
    const log = {
        info: (message: string) => console.log(`[INFO] ${message}`),
        success: (message: string) => console.log(`[SUCCESS] ${message}`),
        warning: (message: string) => console.log(`[WARNING] ${message}`),
        error: (message: string) => console.log(`[ERROR] ${message}`),
        header: (message: string) => console.log(`\n${message}\n`),
    };
    
    // Preloading configuration
    const MAX_PRELOAD_BYTES = Number(
        process.env.ASSET_PRELOAD_MAX_SIZE ?? 5 * 1024 * 1024
    );
    
    const INCLUDE_PATTERNS = (process.env.ASSET_PRELOAD_INCLUDE_PATTERNS ?? "")
        .split(",")
        .map((s) => s.trim())
        .filter(Boolean)
        .map((pattern) => convertGlobToRegExp(pattern));
    
    const EXCLUDE_PATTERNS = (process.env.ASSET_PRELOAD_EXCLUDE_PATTERNS ?? "")
        .split(",")
        .map((s) => s.trim())
        .filter(Boolean)
        .map((pattern) => convertGlobToRegExp(pattern));
    
    const VERBOSE = process.env.ASSET_PRELOAD_VERBOSE_LOGGING === "true";
    const ENABLE_ETAG = (process.env.ASSET_PRELOAD_ENABLE_ETAG ?? "true") === "true";
    const ENABLE_GZIP = (process.env.ASSET_PRELOAD_ENABLE_GZIP ?? "true") === "true";
    const GZIP_MIN_BYTES = Number(process.env.ASSET_PRELOAD_GZIP_MIN_SIZE ?? 1024);
    const GZIP_TYPES = (
        process.env.ASSET_PRELOAD_GZIP_MIME_TYPES ??
        "text/,application/javascript,application/json,application/xml,image/svg+xml"
    )
        .split(",")
        .map((v) => v.trim())
        .filter(Boolean);
    
    function convertGlobToRegExp(globPattern: string): RegExp {
        const escapedPattern = globPattern
            .replace(/[-/\\^$+?.()|[\]{}]/g, "\\$&")
            .replace(/\*/g, ".*");
        return new RegExp(`^${escapedPattern}$`, "i");
    }
    
    function computeEtag(data: Uint8Array): string {
        const hash = createHash("md5").update(data).digest("hex");
        return `W/"${hash.substring(0, 8)}-${data.byteLength.toString()}"`;
    }
    
    interface AssetMetadata {
        route: string;
        size: number;
        type: string;
    }
    
    interface InMemoryAsset {
        raw: Uint8Array;
        gz?: Uint8Array;
        etag?: string;
        type: string;
        immutable: boolean;
        size: number;
    }
    
    interface PreloadResult {
        assets: Map<string, InMemoryAsset>;
        onDemand: Map<string, { filepath: string; type: string }>;
        loaded: AssetMetadata[];
        skipped: AssetMetadata[];
    }
    
    function isFileEligibleForPreloading(relativePath: string): boolean {
        const fileName = relativePath.split(/[/\\]/).pop() ?? relativePath;
    
        if (INCLUDE_PATTERNS.length > 0) {
            if (!INCLUDE_PATTERNS.some((pattern) => pattern.test(fileName))) {
                return false;
            }
        }
    
        if (EXCLUDE_PATTERNS.some((pattern) => pattern.test(fileName))) {
            return false;
        }
    
        return true;
    }
    
    function isMimeTypeCompressible(mimeType: string): boolean {
        return GZIP_TYPES.some((type) =>
            type.endsWith("/") ? mimeType.startsWith(type) : mimeType === type
        );
    }
    
    function compressDataIfAppropriate(
        data: Uint8Array,
        mimeType: string
    ): Uint8Array | undefined {
        if (!ENABLE_GZIP) return undefined;
        if (data.byteLength < GZIP_MIN_BYTES) return undefined;
        if (!isMimeTypeCompressible(mimeType)) return undefined;
        try {
            return new Uint8Array(gzipSync(data));
        } catch {
            return undefined;
        }
    }
    
    function createAssetResponse(asset: InMemoryAsset, req: Request): Response {
        const headers: Record<string, string> = {
            "Content-Type": asset.type,
            "Cache-Control": asset.immutable
                ? "public, max-age=31536000, immutable"
                : "public, max-age=3600",
        };
    
        if (ENABLE_ETAG && asset.etag) {
            const ifNone = req.headers.get("if-none-match");
            if (ifNone && ifNone === asset.etag) {
                return new Response(null, {
                    status: 304,
                    headers: { ETag: asset.etag },
                });
            }
            headers.ETag = asset.etag;
        }
    
        if (
            ENABLE_GZIP &&
            asset.gz &&
            req.headers.get("accept-encoding")?.includes("gzip")
        ) {
            headers["Content-Encoding"] = "gzip";
            headers["Content-Length"] = String(asset.gz.byteLength);
            return new Response(Buffer.from(asset.gz), { status: 200, headers });
        }
    
        headers["Content-Length"] = String(asset.raw.byteLength);
        return new Response(Buffer.from(asset.raw), { status: 200, headers });
    }
    
    async function initializeStaticRoutes(
        clientDirectory: string
    ): Promise<PreloadResult> {
        const assets = new Map<string, InMemoryAsset>();
        const onDemand = new Map<string, { filepath: string; type: string }>();
        const loaded: AssetMetadata[] = [];
        const skipped: AssetMetadata[] = [];
    
        log.info(`Loading static assets from ${clientDirectory}...`);
        if (VERBOSE) {
            console.log(
                `Max preload size: ${(MAX_PRELOAD_BYTES / 1024 / 1024).toFixed(2)} MB`
            );
            if (INCLUDE_PATTERNS.length > 0) {
                console.log(
                    `Include patterns: ${process.env.ASSET_PRELOAD_INCLUDE_PATTERNS ?? ""}`
                );
            }
            if (EXCLUDE_PATTERNS.length > 0) {
                console.log(
                    `Exclude patterns: ${process.env.ASSET_PRELOAD_EXCLUDE_PATTERNS ?? ""}`
                );
            }
        }
    
        let totalPreloadedBytes = 0;
    
        try {
            const files = await glob("**/*", {
                cwd: clientDirectory,
                nodir: true,
                absolute: false,
            });
    
            for (const relativePath of files) {
                const filepath = path.join(clientDirectory, relativePath);
                const route = `/${relativePath.split(path.sep).join(path.posix.sep)}`;
    
                try {
                    const fileStat = await stat(filepath);
                    if (fileStat.size === 0) continue;
    
                    const mimeType = lookup(filepath) || "application/octet-stream";
                    const metadata: AssetMetadata = {
                        route,
                        size: fileStat.size,
                        type: mimeType,
                    };
    
                    const matchesPattern = isFileEligibleForPreloading(relativePath);
                    const withinSizeLimit = fileStat.size <= MAX_PRELOAD_BYTES;
    
                    if (matchesPattern && withinSizeLimit) {
                        const bytes = new Uint8Array(await readFile(filepath));
                        const gz = compressDataIfAppropriate(bytes, mimeType);
                        const etag = ENABLE_ETAG ? computeEtag(bytes) : undefined;
                        const asset: InMemoryAsset = {
                            raw: bytes,
                            gz,
                            etag,
                            type: mimeType,
                            immutable: route.includes("/assets/"),
                            size: bytes.byteLength,
                        };
                        assets.set(route, asset);
                        loaded.push({ ...metadata, size: bytes.byteLength });
                        totalPreloadedBytes += bytes.byteLength;
                    } else {
                        onDemand.set(route, { filepath, type: mimeType });
                        skipped.push(metadata);
                    }
                } catch (error: unknown) {
                    if (error instanceof Error && !error.message.includes("EISDIR")) {
                        log.error(`Failed to load ${filepath}: ${error.message}`);
                    }
                }
            }
    
            if (VERBOSE && (loaded.length > 0 || skipped.length > 0)) {
                const maxPathLength = Math.min(
                    Math.max(...[...loaded, ...skipped].map((f) => f.route.length)),
                    60
                );
    
                if (loaded.length > 0) {
                    console.log("\n📁 Preloaded into memory:");
                    console.log(
                        "Path                                          │    Size │ Gzip Size"
                    );
                    loaded
                        .sort((a, b) => a.route.localeCompare(b.route))
                        .forEach((file) => {
                            const kb = file.size / 1024;
                            const gzipKb = kb * 0.35;
                            const paddedPath = file.route.padEnd(maxPathLength);
                            console.log(
                                `${paddedPath} │ ${kb.toFixed(2).padStart(7)} kB │  ${gzipKb.toFixed(2).padStart(7)} kB`
                            );
                        });
                }
    
                if (skipped.length > 0) {
                    console.log("\n💾 Served on-demand:");
                    skipped.sort((a, b) => a.route.localeCompare(b.route)).forEach((file) => {
                        const kb = file.size / 1024;
                        console.log(`  ${file.route} (${kb.toFixed(2)} kB)`);
                    });
                }
            }
    
            console.log();
            if (loaded.length > 0) {
                log.success(
                    `Preloaded ${loaded.length} files (${(totalPreloadedBytes / 1024 / 1024).toFixed(2)} MB) into memory`
                );
            } else {
                log.info("No files preloaded into memory");
            }
    
            if (skipped.length > 0) {
                const tooLarge = skipped.filter((f) => f.size > MAX_PRELOAD_BYTES).length;
                const filtered = skipped.length - tooLarge;
                log.info(
                    `${skipped.length} files will be served on-demand (${tooLarge} too large, ${filtered} filtered)`
                );
            }
        } catch (error) {
            log.error(
                `Failed to load static files from ${clientDirectory}: ${String(error)}`
            );
        }
    
        return { assets, onDemand, loaded, skipped };
    }
    
    async function initializeServer() {
        log.header("🚀 Starting TanStack Start Production Server");
    
        // Load TanStack Start server handler
        let handler: { fetch: (request: Request) => Response | Promise<Response> };
        try {
            const serverModule = (await import(SERVER_ENTRY_POINT)) as {
                default: { fetch: (request: Request) => Response | Promise<Response> };
            };
            handler = serverModule.default;
            log.success("TanStack Start application handler initialized");
        } catch (error) {
            log.error(`Failed to load server handler: ${String(error)}`);
            process.exit(1);
        }
    
        // Preload static assets
        const { assets, onDemand } = await initializeStaticRoutes(CLIENT_DIRECTORY);
    
        const app = new Hono();
    
        // Serve preloaded assets from memory
        app.get("*", async (c: Context, next) => {
            const pathname = new URL(c.req.url).pathname;
    
            // Check preloaded assets first
            const asset = assets.get(pathname);
            if (asset) {
                return createAssetResponse(asset, c.req.raw);
            }
    
            // Check on-demand assets
            const onDemandAsset = onDemand.get(pathname);
            if (onDemandAsset) {
                const stream = createReadStream(onDemandAsset.filepath);
                return new Response(stream as unknown as ReadableStream, {
                    headers: {
                        "Content-Type": onDemandAsset.type,
                        "Cache-Control": pathname.includes("/assets/")
                            ? "public, max-age=31536000, immutable"
                            : "public, max-age=3600",
                    },
                });
            }
    
            await next();
        });
    
        // Fallback to TanStack Start handler for SSR routes
        app.all("*", async (c: Context) => {
            try {
                return await handler.fetch(c.req.raw);
            } catch (error) {
                log.error(`Server handler error: ${String(error)}`);
                return c.text("Internal Server Error", 500);
            }
        });
    
        // Start the server
        serve(
            {
                fetch: app.fetch,
                port: SERVER_PORT,
            },
            (info: { port: number }) => {
                log.success(`Server listening on http://localhost:${info.port}`);
            }
        );
    }
    
    // Initialize the server
    initializeServer().catch((error: unknown) => {
        log.error(`Failed to start server: ${String(error)}`);
        process.exit(1);
    });
    
    
  12. CarlosZiegler commented on Feb 20, 2026

    @CarlosZiegler

    Hey, ran into this exact issue with TanStack Start v1.161.1 + Bun 1.3.9 in a multi-stage Docker build. The prerender step was trying to hit http://localhost:35537/ (random port) and getting ConnectionRefused.

    Adding preview.host to the vite config fixed it:

      // vite.config.ts
      export default defineConfig({
        preview: {
          host: '127.0.0.1',
        },
        // ... rest of config
      })

    Forces the preview server to explicitly bind to the loopback address inside the container. After that, all pages prerender fine during docker build. Hope this helps someone.

  13. alxwlw commented on Nov 26, 2026

    @alxwlw

    This adds the exact condition under which the prerender request is refused, and where Node and Bun stand on current releases, in case it helps with documenting the Docker case as discussed in #6305.

    Versions: @tanstack/react-start 1.169.7, @tanstack/start-plugin-core 1.172.0, vite 8.4.0. Minimal SPA-mode app (tanstackStart({ spa: { enabled: true } }), one route), vite build inside docker run --rm ubuntu:24.04 on Docker's default bridge network (Docker 29.10.0, Linux x64 host).

    Result on Node 22.23.3, 24.22.2 and 26.8.1: exit code 1, here from the 26.8.1 run:

    [prerender] Prerendered 0 pages:
    [TypeError: fetch failed] {
      [cause]: Error: connect ECONNREFUSED 127.0.0.1:36119
    

    Why: in 1.172.0 the plugin starts vite.preview({ preview: { port: 0, open: false } }) and requests previewServer.resolvedUrls.local[0]. In that container Vite reports http://localhost:<port>/ while its socket is bound to ::1, because localhost resolves differently for listening and for connecting:

    $ grep localhost /etc/hosts
    127.0.0.1	localhost
    ::1	localhost ip6-localhost ip6-loopback
    $ cat /proc/net/if_inet6
    00000000000000000000000000000001 01 80 10 80       lo
    $ node -e 'const d=require("dns");for(const h of [0,d.ADDRCONFIG])d.lookup("localhost",{all:true,hints:h},(e,a)=>console.log(h?"connect:":"listen: ",a.map(x=>x.address)))'
    listen:  [ '::1', '127.0.0.1' ]
    connect: [ '127.0.0.1', '127.0.0.1' ]
    

    listen("localhost") binds the first address of the plain lookup (::1). net.connect resolves with the dns.ADDRCONFIG hint, and with it the ::1 result is gone as long as lo is the only interface that has an IPv6 address. That is what a container on Docker's default bridge looks like here: net.ipv6.conf.eth0.disable_ipv6 is 1, while /etc/hosts still maps ::1 to localhost. Both parts are needed; changing either one makes the same build print Prerendered 1 pages (Node 26.8.1):

    • a hosts file whose ::1 line does not name localhost: both lookups return only 127.0.0.1;
    • the same hosts file with IPv6 enabled on the container's eth0 (a link-local address is enough): both lookups return ::1 first.

    Bun, same container and project (bun --bun node_modules/vite/bin/vite.js build): 1.3.5, 1.3.9 and 1.4.0 fail with the message quoted in this thread (Unable to connect. Is the computer able to access the url?, path: "http://localhost:<port>/", code: "ConnectionRefused"); 1.4.1 and 1.4.5 prerender the page.

    Workarounds: preview: { host: '127.0.0.1' } from the comment above passes on these versions (run on Node 26.8.1). Without touching the Vite config, NODE_OPTIONS=--dns-result-order=ipv4first for the build step passes too (Node 26.8.1): the preview server then binds 127.0.0.1.

    Not run: docker build / BuildKit itself (only docker run), Docker Desktop on macOS, the Nitro plugin setup from the original report, preview.host: true, the branch of #6305. What the plugin calls is read from the published 1.172.0 package, and the listen side from Node's lib/net.js; the ADDRCONFIG hint on connect was logged through a custom lookup on Node 26.8.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions