undici: Multiple requests to the same endpoint cause an error and the container is restarted

Bug Description

With version 3.3.3 it is reporting this error when making several requests.

{"level":30,"time":1614213891203,"pid":28,"hostname":"host removed","msg":"Server listening at http://[::]:8080"}
^[[A^[[A^[[B^[[B{"level":30,"time":1614213926009,"pid":28,"hostname":"host removed","reqId":1,"req":{"method":"GET","url":"/playground","hostname":"10.9.0.26:8080","remoteAddress":"::ffff:10.254.252.71","remotePort":49462},"msg":"incoming request"}
{"level":30,"time":1614213926101,"pid":28,"hostname":"host removed","reqId":1,"res":{"statusCode":200},"responseTime":91.69444751739502,"msg":"request completed"}
{"level":30,"time":1614213926512,"pid":28,"hostname":"host removed","reqId":2,"req":{"method":"GET","url":"/playground/init.js","hostname":"10.9.0.26:8080","remoteAddress":"::ffff:10.254.252.71","remotePort":49462},"msg":"incoming request"}
{"level":30,"time":1614213926513,"pid":28,"hostname":"host removed","reqId":2,"res":{"statusCode":200},"responseTime":1.1579179763793945,"msg":"request completed"}
{"level":30,"time":1614213927824,"pid":28,"hostname":"host removed","reqId":3,"req":{"method":"POST","url":"/graphql","hostname":"10.9.0.26:8080","remoteAddress":"::ffff:10.254.252.71","remotePort":49467},"msg":"incoming request"}
{"level":30,"time":1614213928002,"pid":28,"hostname":"host removed","reqId":3,"res":{"statusCode":200},"responseTime":177.4089002609253,"msg":"request completed"}
{"level":30,"time":1614213945835,"pid":28,"hostname":"host removed","reqId":4,"req":{"method":"POST","url":"/graphql","hostname":"10.9.0.26:8080","remoteAddress":"::ffff:10.254.252.71","remotePort":49482},"msg":"incoming request"}
{"level":30,"time":1614213946595,"pid":28,"hostname":"host removed","reqId":4,"res":{"statusCode":200},"responseTime":760.1512966156006,"msg":"request completed"}
{"level":30,"time":1614213950871,"pid":28,"hostname":"host removed","reqId":5,"req":{"method":"GET","url":"/graphql","hostname":"10.9.0.26:8080","remoteAddress":"::ffff:10.254.252.71","remotePort":49484},"msg":"incoming request"}
{"level":50,"time":1614213952295,"pid":28,"hostname":"host removed","stack":"TypeError: Cannot read property 'upgrade' of undefined\n    at Parser.2 (/root/graphql/node_modules/undici/lib/core/client.js:538:17)","type":"Error","msg":"Cannot read property 'upgrade' of undefined"}
error Command failed with exit code 1.

With version v4.0.0-alpha.3 it is reporting this error when several requests are made:

2021-04-16T19:06:28.155564736Z {"level":30,"time":1618599988155,"pid":27,"hostname":"dev-health-journey-ms-7c89556df4-58b6g","reqId":"req-1i","req":{"method":"POST","url":"/graphql","hostname":"host removed","remoteAddress":"10.9.0.33","remotePort":57360},"msg":"incoming request"}
2021-04-16T19:06:28.605019372Z {"level":30,"time":1618599988604,"pid":27,"hostname":"dev-health-journey-ms-7c89556df4-58b6g","reqId":"req-1j","req":{"method":"POST","url":"/graphql","hostname":"host removed","remoteAddress":"10.9.0.33","remotePort":56490},"msg":"incoming request"}
2021-04-16T19:06:28.709425552Z {"level":50,"time":1618599988709,"pid":27,"hostname":"dev-health-journey-ms-7c89556df4-58b6g","generatedMessage":true,"code":"ERR_ASSERTION","expected":true,"operator":"==","stack":"AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:\n\n assert(request)\n\n at Parser.onHeadersComplete (/root/graphql/node_modules/undici/lib/client.js:653:5)\n at wasm_on_headers_complete (/root/graphql/node_modules/undici/lib/client.js:417:28)\n at <anonymous>:wasm-function[8]:0x34d\n at <anonymous>:wasm-function[35]:0x79f\n at <anonymous>:wasm-function[47]:0x5937\n at <anonymous>:wasm-function[46]:0xbbe\n at llhttp_execute (<anonymous>:wasm-function[12]:0x41f)\n at Parser.execute (/root/graphql/node_modules/undici/lib/client.js:524:32)\n at Socket.onSocketData (/root/graphql/node_modules/undici/lib/client.js:885:10)\n at Socket.emit (node:events:378:20)","type":"Error","msg":"The expression evaluated to a falsy value:\n\n assert(request)\n"}
2021-04-16T19:06:28.711560080Z {"level":50,"time":1618599988711,"pid":27,"hostname":"dev-health-journey-ms-7c89556df4-58b6g","reqId":"req-1i","err":{"type":"GraphQLError","message":"Upload attachment error","stack":"UploadAttachmentError: Upload attachment error\n at DocumentService.uploadReimbursementAttachment (/root/graphql/dist/graphql/services/document/index.js:56:19)\n at processTicksAndRejections (node:internal/process/task_queues:94:5)","locations":[{"line":2,"column":3}],"path":["uploadReimbursementAttachment"],"extensions":{"message":"No se pudo completar la carga del archivo","messageCode":"50001"}},"msg":"Upload attachment error"}
2021-04-16T19:06:28.711924502Z {"level":30,"time":1618599988711,"pid":27,"hostname":"dev-health-journey-ms-7c89556df4-58b6g","reqId":"req-1i","res":{"statusCode":200},"responseTime":556.3380651473999,"msg":"request completed"}
2021-04-16T19:06:28.715811536Z second error, exiting
2021-04-16T19:06:28.719117135Z AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:
2021-04-16T19:06:28.719137836Z
2021-04-16T19:06:28.719141137Z assert(currentParser == null)
2021-04-16T19:06:28.719143837Z
2021-04-16T19:06:28.719146137Z at Parser.destroy (/root/graphql/node_modules/undici/lib/client.js:550:5)
2021-04-16T19:06:28.719148637Z at detachSocket (/root/graphql/node_modules/undici/lib/client.js:928:19)
2021-04-16T19:06:28.719151337Z at Socket.onSocketClose (/root/graphql/node_modules/undici/lib/client.js:946:3)
2021-04-16T19:06:28.719155237Z at Socket.emit (node:events:390:22)
2021-04-16T19:06:28.719167738Z at TCP.<anonymous> (node:net:665:12)
2021-04-16T19:06:28.719172538Z at TCP.callbackTrampoline (node:internal/async_hooks:132:14) {
2021-04-16T19:06:28.719176239Z generatedMessage: true,
2021-04-16T19:06:28.719179539Z code: 'ERR_ASSERTION',
2021-04-16T19:06:28.719182739Z actual: false,
2021-04-16T19:06:28.719186139Z expected: true,
2021-04-16T19:06:28.719189639Z operator: '=='
2021-04-16T19:06:28.719192840Z }
2021-04-16T19:06:28.804922296Z error Command failed with exit code 1.
2021-04-16T19:06:28.805118308Z info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Reproducible By

I’m using mercurios.

my mutation is:

mutation uploadReimbursementAttachment($reimbursementAttachmentInput: ReimbursementAttachmentInput!) {
  uploadReimbursementAttachment(reimbursementAttachmentInput: $reimbursementAttachmentInput){
    id,
    name, 
    path
  }
}

reimbursementAttachmentInput is:

{
    "reimbursementAttachmentInput": {
    "id": "1cc040bd-eb68-4fac-8d45-11caa369ac3e",
    "policyId": "123456",
    "clientCodeCore" : "0000012349999",
    "name": "medicine-invoice1.jpg",
    "mimeType": "image/jpg",
    "attachments": "base64 string" // => add base64 image
  }
}

create task runner with postman with 5 to 10 request

Environment

alpine image node v14.16.1

Additional context

it is my fetch function

export const fetch = async (url: string, options: Client.RequestOptions) => {
  const client = new Client(url);
  const response = await client.request(options);
  let data = '';
  for await (const chunk of response.body) {
    data += String(chunk);
  }

  client.close();
  return { ...response, body: data };
};

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 44 (26 by maintainers)

Commits related to this issue

Most upvoted comments

Correct. Maybe let’s create a DanglingResponseError?

Yea I guess that wouldn’t hurt. But in the case of pipelining this is impossible to detect.

I’ll fix it 😃.