Skip to content

TypeError: fetch is not a function #594

Closed

Description

@codebytere

Seen after pulling latest master - I suspect a571938.

Stacktrace
node on git:master ❯ g node land 40757                                12:11PM
TypeError: fetch is not a function
    at wrappedFetch (/Users/codebytere/Developer/node-core-utils/lib/request.js:17:10)
    at Request.fetch (/Users/codebytere/Developer/node-core-utils/lib/request.js:37:12)
    at Request.text (/Users/codebytere/Developer/node-core-utils/lib/request.js:45:17)
    at Request.json (/Users/codebytere/Developer/node-core-utils/lib/request.js:50:29)
    at Request.query (/Users/codebytere/Developer/node-core-utils/lib/request.js:108:31)
    at Request.gql (/Users/codebytere/Developer/node-core-utils/lib/request.js:68:33)
    at LandingSession.warnForWrongBranch (/Users/codebytere/Developer/node-core-utils/lib/landing_session.js:486:65)
    at main (/Users/codebytere/Developer/node-core-utils/components/git/land.js:175:21)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

cc @targos

Activity

  1. targos commented on Nov 17, 2021

    @targos
    Member

    Did you run npm install ?

  2. codebytere commented on Nov 17, 2021

    @codebytere
    MemberAuthor

    @targos yes, and removed node_modules beforehand to be doubly sure! Using Node.js v16.2.0.

    Update - installed v16.13.0 locally and it worked - we should probably error or specify somewhere the base version one now needs to run node-core-utils 🤔

  3. targos commented on Nov 17, 2021

    @targos
    Member

    Oh wow, it looks like undici doesn't always export a fetch function:

    PS C:\git\TEST> volta run --node 16.2.0 node -p "require('undici').fetch"
    undefined
    PS C:\git\TEST> volta run --node 16.13.0 node -p "require('undici').fetch"
    [AsyncFunction: fetch]
    

    I thought it would be a good idea to use the module to give it some real world test coverage...

    @nodejs/undici

  4. targos commented on Nov 17, 2021

    @targos
    Member

    We should probably go back to node-fetch. undici.fetch doesn't work on the latest version of Node.js 14

  5. ronag commented on Nov 17, 2021

    @ronag
    Member

    We only export fetch for node >= 16.5 since we depend on web streams

  6. Ethan-Arrowood commented on Nov 17, 2021

    @Ethan-Arrowood

    That is strange, but I believe Undici fetch is still considered experimental even on node 16. Best to stick to node-fetch for now. I can take a closer look later on as well

  7. codebytere commented on Nov 17, 2021

    @codebytere
    MemberAuthor

    @targos yeah i did see that i docs here - i can open a PR to revert if that's the path forward!

  8. targos commented on Nov 17, 2021

    @targos
    Member

    Go ahead! I removed node-fetch because version 3.x doesn't support commonjs, so you'll have to stay with version 2.x.

  9. codebytere commented on Nov 17, 2021

    @codebytere
    MemberAuthor

    Done: #595

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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