Skip to content

Commit

Permalink
fix(deps): update unidici
Browse files Browse the repository at this point in the history
  • Loading branch information
michalkvasnicak committed Jun 29, 2021
1 parent acfc63c commit fea217c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/packages/engine-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"new-github-issue-url": "^0.2.1",
"p-retry": "^4.2.0",
"terminal-link": "^2.1.1",
"undici": "3.3.6"
"undici": "^4.0.0"
},
"files": [
"README.md",
Expand Down
10 changes: 7 additions & 3 deletions src/packages/engine-core/src/undici.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
import getStream = require('get-stream')
import { Client, Pool } from 'undici'
import { Client, Dispatcher, Pool } from 'undici'
import { URL } from 'url'
export class Undici {
private pool: Pool
private closed = false
private url: string | URL
constructor(url: string | URL, moreArgs?: Pool.Options) {
this.url = url
this.pool = new Pool(url, {
connections: 100,
pipelining: 10,
keepAliveMaxTimeout: 600e3,
headersTimeout: 0,
bodyTimeout: 0,
...moreArgs,
})
}
request(
body: Client.DispatchOptions['body'],
body: Dispatcher.DispatchOptions['body'],
customHeaders?: Record<string, string>,
) {
return new Promise((resolve, reject) => {
this.pool.request(
{
origin: this.url,
path: '/',
method: 'POST',
headers: {
'Content-Type': 'application/json',
...customHeaders,
},
body,
bodyTimeout: 0,
},
async (err, result) => {
if (err) {
Expand All @@ -45,6 +48,7 @@ export class Undici {
return new Promise((resolve, reject) => {
this.pool.request(
{
origin: this.url,
path: '/',
method: 'GET',
},
Expand Down

0 comments on commit fea217c

Please sign in to comment.