Fetch fails on Node.js (WebAssembly error)

Abierto
#1,287 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
15/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
javascript, nodejs, swift
Área
devtools, mobile

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.
Lenguaje dominante
Swift
Estrellas
4k
Forks
376
Merge medio
1 min
PR fusionados (30 d)
1

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de thebaselab/codeapp

Todos los issues de thebaselab/codeapp

Issues similares

Más issues de Swift

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.