Skip to content

Bug: I get "TypeError: Illegal invocation" when using node-fetch@3 with electron #917

@badersur

Description

@badersur

I'm not sure if this is a bug but I think so. I have an electron app that uses node-fetch@2 which is working fine (in a GUI and the terminal), but with version 3 when I only run the app in the terminal (I get a TypeError when run in the GUI).

This is maybe due to dropping support for the browser but I don't think so! The app uses node-fetch in the GUI using a preload script which have access to full node APIs as far as I understand, and it should be running as if it's running from a terminal! Or maybe it's an issue with Electron itself?!

Reproduction

Steps to reproduce the behavior:
Using node >=12.14.1 should be fine but I use version 14.8.0.

  1. git clone https://github.com/badersur/miniapp.git
  2. cd miniapp
  3. git checkout node-fetch-3
  4. yarn
  5. yarn dev

Edit: Or download v1.0.1-next of the app and run it to see the error on the GUI, and run miniapp -t to output to the terminal with no error!

Expected behavior
The app should work fine as shown in the master branch:

git checkout master
yarn
yarn dev
# Passing `-t` to the app will output to the terminal (which is working fine using both versions), for Linux I use:
yarn dist:dir && ./dist/linux-unpacked/miniapp -t

Edit: Or download v1.0.0 of the app and run it with or without -t flag to see the app running without any issues!

Screenshots

Screenshot from 2020-08-18 18-11-01

Your Environment

software version
node-fetch 3.0.0-beta.8
node 14.8.0
npm 6.14.7
yarn 1.22.4
Operating System Ubuntu 20.04.1 LTS

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions