Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undici throws a terminated error #1490

Closed
Eddy84 opened this issue Jun 12, 2022 · 17 comments
Closed

Undici throws a terminated error #1490

Eddy84 opened this issue Jun 12, 2022 · 17 comments
Labels
Status: wontfix This will not be worked on

Comments

@Eddy84
Copy link

Eddy84 commented Jun 12, 2022

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
dotansimha/graphql-code-generator#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.
`
@mcollina
Copy link
Member

Thanks for reporting.
Can you provide steps to reproduce with just Undici? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.

@d1urno
Copy link

d1urno commented Jul 11, 2022

@Eddy84 I'm experiencing the same issue, did you manage to solve this?

@d1urno
Copy link

d1urno commented Jul 11, 2022

Downgrading node version from 18 to 16 (stable) did the trick for me.

@LiamKarlMitchell
Copy link

Same issue, but already on v16.14.0, v16.16.0 made no difference and it was working last week.
Laravel Lighthouse + Graphql code gen.

@hpiaia
Copy link

hpiaia commented Jul 27, 2022

@LiamKarlMitchell did you found any solution for that?
I am trying to use it with Laravel Lighthouse and have the same problem.
Node v16.16.0

@thomasaull
Copy link

@hpiaia Check my comment in this other issue dotansimha/graphql-code-generator#7934 (comment) for a workaround.

@LiamKarlMitchell
Copy link

LiamKarlMitchell commented Jul 27, 2022 via email

@hpiaia
Copy link

hpiaia commented 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

@mcollina
Copy link
Member

I'm closing this as won't fix. I will happy to review again when/if we have a reproduction for the problem.

@mcollina mcollina closed this as not planned Won't fix, can't repro, duplicate, stale Jul 31, 2022
@mcollina mcollina added Status: wontfix This will not be worked on and removed bug Something isn't working labels Jul 31, 2022
@thomasaull
Copy link

@mcollina I'd be happy to provde a reproduction. However since this is happening in a mixedx project with php laravel and javascript, I'm not sure what would be the best way to do this?

@mcollina
Copy link
Member

mcollina commented Aug 1, 2022

Try to reproduce with just undici and Node.js. Things that work well:

  1. use wireshark to see what's going on at the protocol level
  2. use net.createServer to reproduce that server

@thomasaull
Copy link

@mcollina Had no luck reproducing it with node :-/

@michaelglass
Copy link

happens periodically for us as well using node 18 with undici 5.22.1. No clear reproducer but we see it daily.

@jacobshirley
Copy link

Happens to us, using Node 20 in a Google Cloud Functions, however works fine locally

@kevinrss01
Copy link

Happens also periodically for me using node 20 and nest.js - No clear reproducer but we see it daily.
Happens only on long request (+15min)

@Shabinder
Copy link

+1, Affected by this, inconsistently, no defined cause.

@undergroundwires
Copy link

Happens when IPv6 is disabled. Reproduce on Ubuntu:

  echo '1' | sudo tee /proc/sys/net/ipv6/conf/all/disable_ipv6 > /dev/null
  echo '1' | sudo tee /proc/sys/net/ipv6/conf/default/disable_ipv6 > /dev/null

Fetch usage with node results in exit code 13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

12 participants