Skip to content

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

@senluowx

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions