Fetch fails on Node.js (WebAssembly error)

未关闭
#1,287 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
15/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
javascript, nodejs, swift
领域
devtools, mobile

调研方向

The stack trace points into the bundled undici fetch implementation: lazyllhttp in lib/client.js throws WebAssembly is not defined, so the failure is in the Node runtime the app embeds, not in the Swift UI. Start by checking whether that runtime exposes a global WebAssembly object, then run the fetch snippet from the issue to reproduce. Done means await fetch(...) resolves on the device and the process exits without Ctrl+C.

由索引模型根据 Issue 内容生成。

描述

What Happened:

I was unable to use await fetch() nor fetch().then() on Node.js for this application.

Version this happens on:

The latest version available on the App Store & The Beta TestFlight

How to re-create

  1. Create a file called test.js
  2. Write down this code:
await fetch("https://jsonplaceholder.typicode.com/posts/1"); // Use any API
  1. Execute the file. You may need to allow ESM modules.

Error Dump

Solution 1 $ node /var/mobile/Containers/Data/Application/A3048ECB-6A9D-46F6-AC58-CDC31F18DB0B/Documents/node/Solutions/Solution 1/test.js
ReferenceError: WebAssembly is not defined
    at lazyllhttp (node:internal/deps/undici/undici:7804:9)
    at lib/client.js (node:internal/deps/undici/undici:7850:25)
    at __require (node:internal/deps/undici/undici:6:50)
    at lib/pool.js (node:internal/deps/undici/undici:9173:18)
    at __require (node:internal/deps/undici/undici:6:50)
    at lib/agent.js (node:internal/deps/undici/undici:9255:16)
    at __require (node:internal/deps/undici/undici:6:50)
    at lib/global.js (node:internal/deps/undici/undici:9376:17)
    at __require (node:internal/deps/undici/undici:6:50)
    at lib/fetch/index.js (node:internal/deps/undici/undici:9464:35)
TypeError: fetch failed
    at Object.fetch (node:internal/deps/undici/undici:11730:11)
    at async file:///private/var/mobile/Containers/Data/Application/A3048ECB-6A9D-46F6-AC58-CDC31F18DB0B/Documents/node/Solutions/Solution%201/test.js:1:1 {
  cause: ReferenceError: WebAssembly is not defined
      at lazyllhttp (node:internal/deps/undici/undici:7804:9)
      at lib/client.js (node:internal/deps/undici/undici:7850:25)
      at __require (node:internal/deps/undici/undici:6:50)
      at lib/pool.js (node:internal/deps/undici/undici:9173:18)
      at __require (node:internal/deps/undici/undici:6:50)
      at lib/agent.js (node:internal/deps/undici/undici:9255:16)
      at __require (node:internal/deps/undici/undici:6:50)
      at lib/global.js (node:internal/deps/undici/undici:9376:17)
      at __require (node:internal/deps/undici/undici:6:50)
      at lib/fetch/index.js (node:internal/deps/undici/undici:9464:35)
}
  1. The code will not execute properly. Depending on how it is written, it will either gracefully handle the fetch or error out.
  2. A pattern I discovered is that you had to press the CTRL+C to quit the application, meaning that Node.js doesn’t quit.
主要语言
Swift
星标
4k
派生
376
平均合并
1 分钟
30 天内合并 PR
1

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

thebaselab/codeapp 的其他 Issue

查看 thebaselab/codeapp 的全部 Issue

相似的 Issue

更多 Swift Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。