Fetch fails on Node.js (WebAssembly error)

Đang mở
#1,287 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
15/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, nodejs, swift
Lĩnh vực
devtools, mobile

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
Swift
Star
4k
Fork
376
Merge trung bình
1 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của thebaselab/codeapp

Tất cả issue của thebaselab/codeapp

Issue tương tự

Thêm issue về Swift

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.