Registry Mirror
Skip to content

Windows global fetch links no-op stub instead of stdlib implementation #5000

Closed

Description

@senluowx

What happened

Using the documented global Fetch API on Windows compiles successfully, but the generated binary runs with runtime no-op stubs instead of the real perry-stdlib fetch implementation. At runtime, response.json() fails with Error: Invalid response handle.

The runtime prints these warnings before the error:

[perry] warning: `js_stdlib_init_dispatch` is a no-op stub on this platform — stdlib dispatch symbol from perry-stdlib not linked into this binary (runtime-only build)
[perry] warning: `js_fetch_with_options` is a no-op stub on this platform — fetch symbol from perry-stdlib not linked into this binary (runtime-only build)
Error: Invalid response handle
    at <anonymous>

What you expected

The documented global fetch(...) example should link the real perry-stdlib fetch implementation on Windows. await fetch(...) should return a valid Response, await response.json() should parse the body, and result.status should contain the HTTP status code.

Minimal reproduction

// GET request
const response = await fetch("https://jsonplaceholder.typicode.com/posts/1");
const data = await response.json();

// POST request
const result = await fetch("https://jsonplaceholder.typicode.com/posts", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ title: "hello", body: "world", userId: 1 }),
});

console.log(`fetch ok: ${data !== null} status=${result.status}`);

Command you ran:

perry compile src/main.ts -o main.exe
./main.exe

Environment

  • Perry version: perry 0.5.1129
  • Host OS: Microsoft Windows 11 Pro
  • Target: native Windows
  • Rust toolchain (if building from source): not applicable
  • Installed via: winget (winget install PerryTS.Perry)

Diagnostic output

Runtime output:

[perry] warning: `js_stdlib_init_dispatch` is a no-op stub on this platform — stdlib dispatch symbol from perry-stdlib not linked into this binary (runtime-only build)
[perry] warning: `js_fetch_with_options` is a no-op stub on this platform — fetch symbol from perry-stdlib not linked into this binary (runtime-only build)
Error: Invalid response handle
    at <anonymous>

perry check --check-deps src/main.ts passes for the minimal reproduction, but the compiled binary appears to use runtime-only stubs for fetch/stdlib dispatch.

Anything else

This looks related to Windows final linking / stdlib symbol selection rather than a JavaScript-level fetch error. It is not the same as #732 (winhttp.lib missing), but it seems similar in that the Windows final binary does not get the expected native stdlib implementation.

I also saw this in a perry/ui app: fetch only resumed after another UI/timer event, and the returned response had status=0; response.json() / response.text() then failed with Invalid response handle. A CLI-only minimal reproduction above is enough to show the stub-linking problem.

Activity

  1. added
    type:bug
    on Jun 11, 2026
  2. senluowx commented on Jun 15, 2026

    @senluowx
    Author

    Update: I tested this again with Perry 0.5.1167 installed via winget, and the issue still reproduces without PERRY_WORKSPACE_ROOT.

    The winget installation contains the prebuilt libraries:

    <winget-package-dir>/PerryTS.Perry_*/
    
    perry.exe
    perry_runtime.lib
    perry_stdlib.lib
    perry_ui_windows.lib
    

    So this does not appear to be a missing stdlib file. The compiler also prints:

    Linking (with stdlib)...
    

    However, the Windows linker reports duplicate symbols between perry_runtime.lib and perry_stdlib.lib, for example:

    lld-link: warning: duplicate symbol: js_fetch_with_options
    >>> defined at perry_runtime.lib(...)
    >>> defined at perry_stdlib.lib(...)
    
    lld-link: warning: duplicate symbol: js_stdlib_init_dispatch
    >>> defined at perry_runtime.lib(...)
    >>> defined at perry_stdlib.lib(...)
    

    The resulting executable still calls the runtime no-op stubs:

    [perry] warning: `js_stdlib_init_dispatch` is a no-op stub on this platform — stdlib dispatch symbol from perry-stdlib not linked into this binary (runtime-only build)
    [perry] warning: `js_fetch_with_options` is a no-op stub on this platform — fetch symbol from perry-stdlib not linked into this binary (runtime-only build)
    Error: Invalid response handle
        at <anonymous>
    

    I also found a workaround. If I set PERRY_WORKSPACE_ROOT to a local Perry source checkout and force a rebuild, the generated executable works correctly:

    env PERRY_WORKSPACE_ROOT=<path-to-perry-source-checkout> perry compile src/main.ts -o main.exe --no-cache
    ./main.exe

    Output:

    fetch ok: true status=201
    

    During this working build, Perry prints:

    auto-optimize: rebuilding runtime+stdlib (panic=abort, features=crypto,http-client)
    

    So the issue seems specific to the winget/prebuilt Windows runtime+stdlib link path. When runtime+stdlib are rebuilt from source via PERRY_WORKSPACE_ROOT, fetch resolves to the real stdlib implementation and works.

    This suggests the problem may be related to Windows prebuilt archive symbol resolution, duplicate symbol handling, or link order between perry_runtime.lib and perry_stdlib.lib.

  3. jroweboy commented on Jun 16, 2026

    @jroweboy

    I linked back to this in another issue, but I've encountered this bug as well, and its not limited to just fetch. It was happening for me with process.stdin on windows also.

  4. added a commit that references this issue on Jun 25, 2026
  5. added 2 commits that reference this issue on Jul 3, 2026
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

    type:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions