Fetch fails on Node.js (WebAssembly error)

Aperta
#1,287 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
15/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript, nodejs, swift
Ambito
devtools, mobile

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
Swift
Stelle
4k
Fork
376
Merge medio
1m
PR unite (30g)
1

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di thebaselab/codeapp

Tutte le issue di thebaselab/codeapp

Issue simili

Altre issue su Swift

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.