Skip to content

Commit 543e490

Browse files
ardatangithub-actions[bot]
andauthoredFeb 10, 2023
Update whatwg-node for performance improvements (#2421)
* Bump `whatwg-node` for performance improvements * chore(dependencies): updated changesets for modified dependencies * Fix tests * Bump more * chore(dependencies): updated changesets for modified dependencies --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 0104e69 commit 543e490

15 files changed

+130
-45
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-yoga/plugin-apollo-inline-trace': patch
3+
---
4+
dependencies updates:
5+
- Updated dependency [`@whatwg-node/fetch@^0.8.1` ↗︎](https://www.npmjs.com/package/@whatwg-node/fetch/v/0.8.1) (from `^0.7.1`, in `peerDependencies`)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-yoga/plugin-apq': patch
3+
---
4+
dependencies updates:
5+
- Updated dependency [`@whatwg-node/fetch@^0.8.1` ↗︎](https://www.npmjs.com/package/@whatwg-node/fetch/v/0.8.1) (from `^0.7.1`, in `dependencies`)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'graphql-yoga': patch
3+
---
4+
dependencies updates:
5+
- Updated dependency [`@whatwg-node/fetch@^0.8.1` ↗︎](https://www.npmjs.com/package/@whatwg-node/fetch/v/0.8.1) (from `^0.7.1`, in `dependencies`)
6+
- Updated dependency [`@whatwg-node/server@^0.6.7` ↗︎](https://www.npmjs.com/package/@whatwg-node/server/v/0.6.7) (from `^0.6.5`, in `dependencies`)

‎examples/bun/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
"graphql": "^16.6.0"
1313
},
1414
"devDependencies": {
15-
"@whatwg-node/fetch": "^0.7.1"
15+
"@whatwg-node/fetch": "^0.8.1"
1616
}
1717
}

‎examples/error-handling/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"dependencies": {
1010
"graphql-yoga": "3.5.1",
11-
"@whatwg-node/fetch": "^0.7.1",
11+
"@whatwg-node/fetch": "^0.8.1",
1212
"graphql": "^16.1.0"
1313
},
1414
"devDependencies": {

‎examples/uwebsockets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"uWebSockets.js": "uNetworking/uWebSockets.js#v20.15.0"
1717
},
1818
"devDependencies": {
19-
"@whatwg-node/fetch": "^0.7.1",
19+
"@whatwg-node/fetch": "^0.8.1",
2020
"@types/ws": "8.5.4",
2121
"ws": "8.12.0"
2222
}

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"build": "pnpm --filter=@graphql-yoga/graphiql run build && pnpm --filter=@graphql-yoga/render-graphiql run build && pnpm --filter=graphql-yoga run generate-graphiql-html && bob build",
88
"test": "jest --detectOpenHandles",
99
"test:integration": "cross-env INTEGRATION_TEST=true jest --forceExit",
10-
"test:leaks": "cross-env LEAKS_TEST=true pnpm run test --detectLeaks --logHeapUsage; cross-env LEAKS_TEST=true pnpm run test:integration --detectLeaks --logHeapUsage",
10+
"test:leaks": "cross-env LEAKS_TEST=true pnpm run test --detectLeaks --logHeapUsage && cross-env LEAKS_TEST=true pnpm run test:integration --detectLeaks --logHeapUsage",
1111
"release": "pnpm build && changeset publish",
1212
"start:docs": "pnpm --filter=website dev",
1313
"postinstall": "husky install",

‎packages/graphql-yoga/__tests__/subscriptions.spec.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ function eventStream<TType = unknown>(source: ReadableStream<Uint8Array>) {
2828
}
2929

3030
describe('Subscription', () => {
31+
afterAll((done) => {
32+
setTimeout(done, 4000)
33+
})
3134
test('eventStream', async () => {
3235
const source = (async function* foo() {
3336
yield { hi: 'hi' }
@@ -100,7 +103,7 @@ describe('Subscription', () => {
100103
Subscription: {
101104
hi: {
102105
async *subscribe() {
103-
await new Promise((resolve) => setTimeout(resolve, 10_000))
106+
await new Promise((resolve) => setTimeout(resolve, 5000))
104107
yield { hi: 'hi' }
105108
},
106109
},
@@ -127,17 +130,19 @@ describe('Subscription', () => {
127130

128131
const iterator = response.body![Symbol.asyncIterator]()
129132

133+
let shouldBreak = false
134+
130135
setTimeout(() => {
131-
iterator.return?.()
132-
}, 1500)
136+
shouldBreak = true
137+
}, 2000)
133138

134139
const results = []
135140
// eslint-disable-next-line no-constant-condition
136141
while (true) {
137-
const { done, value } = await iterator.next()
138-
if (done) {
142+
if (shouldBreak) {
139143
break
140144
}
145+
const { value } = await iterator.next()
141146
results.push(Buffer.from(value).toString('utf-8'))
142147
}
143148
expect(results).toMatchInlineSnapshot(`

‎packages/graphql-yoga/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
"@graphql-tools/schema": "^9.0.0",
5656
"@graphql-tools/utils": "^9.2.1",
5757
"@graphql-yoga/subscription": "^3.1.0",
58-
"@whatwg-node/fetch": "^0.7.1",
59-
"@whatwg-node/server": "^0.6.5",
58+
"@whatwg-node/fetch": "^0.8.1",
59+
"@whatwg-node/server": "^0.6.7",
6060
"dset": "^3.1.1",
6161
"lru-cache": "^7.14.1",
6262
"tslib": "^2.3.1"

‎packages/graphql-yoga/src/plugins/requestParser/utils.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { GraphQLParams } from '../../types.js'
2+
import { URLSearchParams } from '@whatwg-node/fetch'
23

34
export function handleURLSearchParams(
45
searchParams: URLSearchParams,

‎packages/graphql-yoga/src/server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ export class YogaServer<
518518
try {
519519
let url = this.urlParseCache.get(request.url)
520520
if (!url) {
521-
url = new URL(request.url, 'http://localhost')
521+
url = new this.fetchAPI.URL(request.url, 'http://localhost')
522522
this.urlParseCache.set(request.url, url)
523523
}
524524
for (const onRequestHook of this.onRequestHooks) {

‎packages/plugins/apollo-inline-trace/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
},
4343
"peerDependencies": {
4444
"@graphql-tools/utils": "^9.0.1",
45-
"@whatwg-node/fetch": "^0.7.1",
45+
"@whatwg-node/fetch": "^0.8.1",
4646
"graphql-yoga": "^3.5.1",
4747
"graphql": "^15.2.0 || ^16.0.0"
4848
},
@@ -52,7 +52,7 @@
5252
},
5353
"devDependencies": {
5454
"@envelop/on-resolve": "^2.0.4",
55-
"@whatwg-node/fetch": "^0.7.1",
55+
"@whatwg-node/fetch": "^0.8.1",
5656
"graphql-yoga": "3.5.1"
5757
}
5858
}

‎packages/plugins/apq/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"access": "public"
4141
},
4242
"dependencies": {
43-
"@whatwg-node/fetch": "^0.7.1",
43+
"@whatwg-node/fetch": "^0.8.1",
4444
"tiny-lru": "^10.0.0"
4545
},
4646
"devDependencies": {

‎packages/plugins/defer-stream/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
},
4646
"devDependencies": {
4747
"@graphql-tools/executor-http": "^0.1.4",
48-
"@whatwg-node/fetch": "^0.7.1"
48+
"@whatwg-node/fetch": "^0.8.1"
4949
},
5050
"type": "module",
5151
"dependencies": {

‎pnpm-lock.yaml

+92-29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.