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.

Undici throws a terminated error

See original GitHub issue

Bug Description

I have a bug with graphl-codegen which is very likely caused by undici closing the connection and sending a terminated signal?

I have double checked my backend with various graphql clients and plain http requests doing the introspection query, the bug is definitely in undici.

The server receives the request, but it is terminated.

A stacktrace is included below:

Here is the related issue https://github.com/dotansimha/graphql-code-generator/issues/7934

Reproducible By

See the linked issue above

Expected Behavior

Return a response

Logs & Screenshots

See below

Environment

  • Ubuntu 20 LTS
  • undici 5.1

Additional context

Stacktrace:

` 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.<anonymous> (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.<anonymous> (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.
`

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
hpiaiacommented, Jul 31, 2022

@thomasaull @LiamKarlMitchell, I got another solution for that, just use node-fetch instead of undici for consuming the api.

schema:
  - http://localhost:8000/graphql:
      customFetch: 'node-fetch'

Reference: https://www.graphql-code-generator.com/docs/config-reference/schema-field#customfetch

1reaction
thomasaullcommented, Jul 27, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

std::terminate
If a destructor reset the terminate handler during stack unwinding, it is unspecified which handler is called if the unwinding later led to...
Read more >
javascript - NodeJS server hangup on stream errror
P.S. As you can see, am using the undici package. Do not use pipeline because pipeline will call res. destroy() when transform throws...
Read more >
I am receiving an error code in the Bloomberg Excel API. What ...
The following error messages indicate that downloading via the Excel ... indicates the subscription has been terminated by the BDP, BPGE, ...
Read more >
Object doesn't support this action' error in IE 11
Internet Explorer (IE) 11 throws "TypeError: Object doesn't support this action" ... rolling icon is raised and still present, the action is not...
Read more >
Chapter 6- Exceptions Flashcards
Problem, and then line 8 calls System.exit, which terminates the JVM. The finally block does not execute ... Line 11 throws the exception...
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