nodejs-mobile / nodejs-mobile

Full-fledged Node.js on Android and iOS
https://nodejs-mobile.github.io
Other
458 stars 44 forks source link

Usage of Node 18 fetch API causes crash due to undefined WebAssembly #71

Open utopalex opened 5 months ago

utopalex commented 5 months ago

Version

v18.17.1

Platform

iOS

Subsystem

undici/fetch

What steps will reproduce the bug?

--compiled from Typescript-- import { fromFetch } from "rxjs/fetch"

.. return fromFetch(url, fetchOptions).pipe(..)

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

No crash. Ideally using the new fetch API available in Node.js 18: https://nodejs.org/en/blog/announcements/v18-release-announce#fetch-experimental

What do you see instead?

Crash. VM3001 undici:9334 Uncaught ReferenceError: WebAssembly is not defined at lazyllhttp (VM3001 undici:9334:9) at lib/client.js (VM3001 undici:9377:25) at require (VM3001 undici:4:50) at lib/pool.js (VM3001 undici:10399:18) at require (VM3001 undici:4:50) at lib/agent.js (VM3001 undici:10475:16) at require (VM3001 undici:4:50) at lib/global.js (VM3001 undici:10589:17) at require (VM3001 undici:4:50) at lib/fetch/index.js (VM3001 undici:10675:35)

Additional information

A workaround is to start node with passing "--no-experimental-fetch".

staltz commented 5 months ago

I am not sure, but I suspect fetch is using undici, which in turn (certainly) uses WASM.

Workaround for now is to avoid fetch.

jadejr commented 2 months ago

what is causing wasm stuff not to work?