ardatan / ardatan/graphql-tools

Url Loader fails to load schema from server

Open
#4,522 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
5.4k
Forks
830
Avg merge
10h 59m
Merged PRs (30d)
45

Description

**Describe the bug**

I get a bug with a fresh project using nextjs and graphql-codegen.
The introspection query fails with a terminated signal.

I have tested my backend to plain http requests to rule out errors on my side
and it works fine,
also older versions of graphql-tools which use older cross-undici-fetch dependencies work fine.

I had a look at the files in the stack trace below, the request.js seems to do some header handling, maybe this is the root of the problem?

There is another issue about headers:
https://github.com/ardatan/graphql-tools/issues/4482

Related issues
https://github.com/dotansimha/graphql-code-generator/issues/7934
https://github.com/nodejs/undici/issues/1490

**To Reproduce**
Steps to reproduce the behavior:

I have added a list how to reproduce it there:

https://github.com/dotansimha/graphql-code-generator/issues/7934

**Expected behavior**

Return the schema response

**Environment:**

- Ubuntu 20 LTS
- Node v16.13.2

**Additional context**

```
`[CLI] Exited with an error DetailedError: Failed to load schema
at loadSchema (/home/eduard/Projects/ecommerce/frontend/node_modules/@graphql-codegen/cli/bin.js:504:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async /home/eduard/Projects/ecommerce/frontend/node_modules/@graphql-codegen/cli/bin.js:1034:65 {
details: '\n' +
' Failed to load schema from http://localhost/service:\n' +
'\n' +
' terminated\n' +
' TypeError: terminated\n' +
' at Fetch.onAborted (/home/eduard/Projects/ecommerce/frontend/node_modules/undici/lib/fetch/index.js:1893:49)\n' +
' at Fetch.emit (node:events:390:28)\n' +
' at Fetch.terminate (/home/eduard/Projects/ecommerce/frontend/node_modules/undici/lib/fetch/index.js:77:10)\n' +
' at Object.onError (/home/eduard/Projects/ecommerce/frontend/node_modules/undici/lib/fetch/index.js:2027:34)\n' +
' at Request.onError (/home/eduard/Projects/ecommerce/frontend/node_modules/undici/lib/core/request.js:237:27)\n' +
' at errorRequest (/home/eduard/Projects/ecommerce/frontend/node_modules/undici/lib/client.js:1711:13)\n' +
' at Socket.onSocketClose (/home/eduard/Projects/ecommerce/frontend/node_modules/undici/lib/client.js:985:5)\n' +
' at Socket.emit (node:events:390:28)\n' +
' at TCP. (node:net:687:12)\n' +
' \n' +
' GraphQL Code Generator supports:\n' +
' - ES Modules and CommonJS exports (export as default or named export "schema")\n' +
' - Introspection JSON File\n' +
' - URL of GraphQL endpoint\n' +
' - Multiple files with type definitions (glob expression)\n' +
' - String in config file\n' +
' \n' +
' Try to use one of above options and run codegen again.\n' +
' \n' +
' ',
source: 'src/',
context: [Object: null prototype] {}
}
Something went wrong Failed to load schema for "src/"
Failed to load schema from http://localhost/service:

terminated
TypeError: terminated
at Fetch.onAborted (/home/eduard/Projects/ecommerce/frontend/node_modules/undici/lib/fetch/index.js:1893:49)
at Fetch.emit (node:events:390:28)
at Fetch.terminate (/home/eduard/Projects/ecommerce/frontend/node_modules/undici/lib/fetch/index.js:77:10)
at Object.onError (/home/eduard/Projects/ecommerce/frontend/node_modules/undici/lib/fetch/index.js:2027:34)
at Request.onError (/home/eduard/Projects/ecommerce/frontend/node_modules/undici/lib/core/request.js:237:27)
at errorRequest (/home/eduard/Projects/ecommerce/frontend/node_modules/undici/lib/client.js:1711:13)
at Socket.onSocketClose (/home/eduard/Projects/ecommerce/frontend/node_modules/undici/lib/client.js:985:5)
at Socket.emit (node:events:390:28)
at TCP. (node:net:687:12)

GraphQL Code Generator supports:
- ES Modules and CommonJS exports (export as default or named export "schema")
- Introspection JSON File
- URL of GraphQL endpoint
- Multiple files with type definitions (glob expression)
- String in config file

Try to use one of above options and run codegen again.

`
```

Contributor guide

Open the contributing guide

Research direction

Start with the linked reproduction in graphql-code-generator issue 7934 and the stack-trace locations in node_modules/undici/lib/core/request.js and client.js. Compare the failing current dependency with older graphql-tools and cross-undici-fetch versions; done means the URL loader successfully returns the schema response instead of terminating.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.