question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Request is not a constructor

See original GitHub issue

This is happening inside cross-undici-fetch (which is a non-src package inside of https://github.com/ardatan/w3-server)

TypeError: Request is not a constructor
    at getNodeRequest (file:///Users/ian/Projects/rel/repo/node_modules/.pnpm/@graphql-yoga+node@0.1.0-alpha.3_graphql@15.8.0/node_modules/@graphql-yoga/node/index.mjs:42:16)
    at YogaNodeServer.handleIncomingMessage (file:///Users/ian/Projects/rel/repo/node_modules/.pnpm/@graphql-yoga+node@0.1.0-alpha.3_graphql@15.8.0/node_modules/@graphql-yoga/node/index.mjs:148:31)
    at Object.handler (file:///Users/ian/Projects/rel/repo/packages/rel-server/dist/index.js:97:44)
    at preHandlerCallback (/Users/ian/Projects/rel/repo/node_modules/.pnpm/fastify@3.25.3/node_modules/fastify/lib/handleRequest.js:126:28)
    at preValidationCallback (/Users/ian/Projects/rel/repo/node_modules/.pnpm/fastify@3.25.3/node_modules/fastify/lib/handleRequest.js:109:5)
    at handler (/Users/ian/Projects/rel/repo/node_modules/.pnpm/fastify@3.25.3/node_modules/fastify/lib/handleRequest.js:72:7)
    at /Users/ian/Projects/rel/repo/node_modules/.pnpm/fastify@3.25.3/node_modules/fastify/lib/contentTypeParser.js:174:9
    at AsyncResource.runInAsyncScope (node:async_hooks:199:9)
    at done (/Users/ian/Projects/rel/repo/node_modules/.pnpm/fastify@3.25.3/node_modules/fastify/lib/contentTypeParser.js:169:14)
    at Parser.defaultJsonParser [as fn] (/Users/ian/Projects/rel/repo/node_modules/.pnpm/fastify@3.25.3/node_modules/fastify/lib/contentTypeParser.js:269:5)

Package:

"@graphql-yoga/node": "^0.1.0-alpha.3",

Have tried with canary as well.

This is happening inside of getNodeRequest and tries to use the cross-undici-fetch Request object:

CleanShot 2022-01-31 at 11 35 20@2x

When I output the default export from Undici it’s missing a ton:

{
    fetch: [Function (anonymous)],
    Headers: undefined,
    Request: undefined,
    Response: undefined,
    FormData: undefined,
    AbortController: [class AbortController],
    ReadableStream: [class ReadableStream],
    WritableStream: [class WritableStream],
    TransformStream: [class TransformStream],
    Blob: [class Blob],
    File: undefined
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15

github_iconTop GitHub Comments

1reaction
iancommented, Jan 31, 2022

@ardatan that worked for me, thanks for the fast turnaround!

0reactions
ardatancommented, Jan 31, 2022

@ian Thank you for reporting this issue!

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: "x" is not a constructor - JavaScript - MDN Web Docs
The JavaScript exception "is not a constructor" occurs when there was an attempt to use an object or a variable as a constructor,...
Read more >
Javascript "Not a Constructor" Exception while creating objects
The reason is that when it is attempting to initialize y, it creates a temporary "y" object (not class, object!) in the dependency...
Read more >
Resolving TypeError: "X" is Not a Constructor in JavaScript
JavaScript "TypeError: "x" is not a constructor" errors occur when invalid objects or a variable is erroneously used as a constructor.
Read more >
JavaScript TypeError - "X" is not a constructor - GeeksforGeeks
This JavaScript exception is not a constructor that occurs if code tries to use an object or a variable as a constructor, which...
Read more >
TypeError: "X" is not a constructor in JavaScript | bobbyhadz
To solve the "TypeError: 'X' is not a constructor" in JavaScript, make sure to only use the new operator on valid constructors, e.g....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found