Skip to content

Commit 5b9ed18

Browse files
Bump bun from 1.2.23 to 1.3.0 in the bun group (#1604)
Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Arda TANRIKULU <[email protected]>
1 parent 606d649 commit 5b9ed18

File tree

15 files changed

+129
-116
lines changed

15 files changed

+129
-116
lines changed

internal/heapsnapshot/src/HeapSnapshotLoader.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
*/
3030

3131
import { MessagePort } from 'node:worker_threads';
32+
import { fakePromise } from '@whatwg-node/promise-helpers';
3233
import {
3334
HeapSnapshotProgress,
3435
JSHeapSnapshot,
@@ -166,7 +167,7 @@ export class HeapSnapshotLoader {
166167
// sequentially. This means it's fine to stash away a single #dataCallback
167168
// instead of an array of them.
168169
if (this.#buffer.length > 0) {
169-
return Promise.resolve(this.#buffer.shift() as string);
170+
return fakePromise(this.#buffer.shift() as string);
170171
}
171172

172173
const { promise, resolve } =

internal/proc/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import childProcess from 'child_process';
22
import fs from 'fs/promises';
33
import path from 'path';
44
import { setTimeout } from 'timers/promises';
5-
import { createDeferred } from '@graphql-tools/utils';
5+
import { createDeferred, fakePromise } from '@graphql-tools/utils';
66
import { hostnames, isDebug, trimError } from '@internal/testing';
77
import { DisposableSymbols } from '@whatwg-node/disposablestack';
88
import { fetch } from '@whatwg-node/fetch';
@@ -127,7 +127,7 @@ export function spawn(
127127
[DisposableSymbols.asyncDispose]: async () => {
128128
if (exited) {
129129
// there's nothing to dispose since the process already exitted (error or not)
130-
return Promise.resolve();
130+
return fakePromise();
131131
}
132132
if (child.pid) {
133133
await terminate(child.pid);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"@yarnpkg/cli": "4.10.3",
4545
"@yarnpkg/core": "4.4.4",
4646
"@yarnpkg/plugin-pack": "4.0.3",
47-
"bun": "1.2.23",
47+
"bun": "1.3.0",
4848
"cross-env": "10.1.0",
4949
"eslint": "9.38.0",
5050
"eslint-plugin-import": "2.32.0",

packages/executors/http/tests/handleEventStreamResponse.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ describe('handleEventStreamResponse', () => {
140140
);
141141
const iterator = asyncIterable[Symbol.asyncIterator]();
142142

143-
Promise.resolve().then(() => {
143+
queueMicrotask(() => {
144144
ctrl.abort(); // we abort
145145
readableStream.cancel(); // then cancel
146146
// so that the error reported is the abort error
@@ -188,7 +188,7 @@ describe('handleEventStreamResponse', () => {
188188
const iterator = asyncIterable[Symbol.asyncIterator]();
189189

190190
const originalError = new Error('Oops!');
191-
Promise.resolve().then(() => {
191+
queueMicrotask(() => {
192192
readableStream.cancel(originalError); // this will throw in reader.read()
193193
});
194194

packages/fusion-runtime/tests/polling.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ describe('Polling', () => {
330330
);
331331
}
332332
makeQuery(10_000);
333-
await advanceTimersByTimeAsync(10_000);
333+
await advanceTimersByTimeAsync(10_500);
334334
makeQuery(0);
335335
expect(callTimes).toHaveLength(2);
336336
// It can be 0 or 1 or any one-digit number

packages/gateway/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@
141141
"@rollup/plugin-sucrase": "^5.0.2",
142142
"@tsconfig/node18": "^18.2.4",
143143
"@types/adm-zip": "^0.5.5",
144-
"@types/bun": "1.2.23",
144+
"@types/bun": "1.3.0",
145145
"@types/ws": "^8.5.12",
146146
"@whatwg-node/fetch": "^0.10.11",
147147
"adm-zip": "^0.5.15",
148-
"bun": "^1.2.23",
148+
"bun": "^1.3.0",
149149
"graphql": "^16.9.0",
150150
"parse-duration": "^2.0.0",
151151
"pkgroll": "2.20.1",

packages/gateway/src/servers/bun.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import { getGraphQLWSOptions } from '@graphql-hive/gateway-runtime';
2-
import type { Server, TLSServeOptions, WebSocketServeOptions } from 'bun';
1+
import {
2+
DisposableSymbols,
3+
getGraphQLWSOptions,
4+
} from '@graphql-hive/gateway-runtime';
5+
import type { Server, WebSocketOptions } from 'bun';
36
import type { Extra } from 'graphql-ws/use/bun';
47
import { defaultOptions, GatewayRuntime } from '..';
58
import type { ServerForRuntimeOptions } from './types';
@@ -8,36 +11,38 @@ export async function startBunServer<TContext extends Record<string, any>>(
811
gwRuntime: GatewayRuntime<TContext>,
912
opts: ServerForRuntimeOptions,
1013
): Promise<void> {
11-
const serverOptions: TLSServeOptions & Partial<WebSocketServeOptions> = {
14+
const serverOptions: Bun.Serve.Options<{}> & Partial<WebSocketOptions> = {
1215
fetch: gwRuntime,
1316
port: opts.port || defaultOptions.port,
1417
hostname: opts.host || defaultOptions.host,
1518
reusePort: true,
1619
idleTimeout: opts.requestTimeout,
1720
};
1821
if (opts.sslCredentials) {
22+
const tlsOptions: Bun.TLSOptions = {};
1923
if (opts.sslCredentials.ca_file_name) {
20-
serverOptions.ca = Bun.file(opts.sslCredentials.ca_file_name);
24+
tlsOptions.ca = Bun.file(opts.sslCredentials.ca_file_name);
2125
}
2226
if (opts.sslCredentials.cert_file_name) {
23-
serverOptions.cert = Bun.file(opts.sslCredentials.cert_file_name);
27+
tlsOptions.cert = Bun.file(opts.sslCredentials.cert_file_name);
2428
}
2529
if (opts.sslCredentials.dh_params_file_name) {
26-
serverOptions.dhParamsFile = opts.sslCredentials.dh_params_file_name;
30+
tlsOptions.dhParamsFile = opts.sslCredentials.dh_params_file_name;
2731
}
2832
if (opts.sslCredentials.key_file_name) {
29-
serverOptions.key = Bun.file(opts.sslCredentials.key_file_name);
33+
tlsOptions.key = Bun.file(opts.sslCredentials.key_file_name);
3034
}
3135
if (opts.sslCredentials.passphrase) {
32-
serverOptions.passphrase = opts.sslCredentials.passphrase;
36+
tlsOptions.passphrase = opts.sslCredentials.passphrase;
3337
}
3438
if (opts.sslCredentials.ssl_ciphers) {
3539
// TODO: Check if there is a correct way to set ciphers
3640
}
3741
if (opts.sslCredentials.ssl_prefer_low_memory_usage) {
38-
serverOptions.lowMemoryMode =
42+
tlsOptions.lowMemoryMode =
3943
opts.sslCredentials.ssl_prefer_low_memory_usage;
4044
}
45+
serverOptions.tls = tlsOptions;
4146
}
4247
if (!opts.disableWebsockets) {
4348
const { makeHandler } = await import('graphql-ws/use/bun');
@@ -47,7 +52,7 @@ export async function startBunServer<TContext extends Record<string, any>>(
4752
...(ctx.extra.socket.data || {}),
4853
})),
4954
);
50-
serverOptions.fetch = function (request: Request, server: Server) {
55+
serverOptions.fetch = function (request: Request, server: Server<{}>) {
5156
// header to check if websocket
5257
if (
5358
request.headers.has('Sec-WebSocket-Key') &&
@@ -65,5 +70,5 @@ export async function startBunServer<TContext extends Record<string, any>>(
6570
}
6671
const server = Bun.serve(serverOptions);
6772
opts.log.info(`Listening on ${server.url}`);
68-
gwRuntime.disposableStack.use(server);
73+
gwRuntime.disposableStack.defer(() => server[DisposableSymbols.dispose]());
6974
}

packages/plugins/opentelemetry/tests/useOpenTelemetry.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,6 @@ describe('useOpenTelemetry', () => {
865865
const operationSpan = spanExporter.spans.find(({ name }) =>
866866
name.startsWith('graphql.operation'),
867867
);
868-
869868
expect(httpSpan.attributes['gateway.cache.response_cache']).toBe(
870869
attrs.http,
871870
);
@@ -1198,7 +1197,7 @@ describe('useOpenTelemetry', () => {
11981197

11991198
it('should have all attributes required by Hive Tracing', async () => {
12001199
await using gateway = await buildTestGateway({
1201-
fetch: () => () => Promise.resolve(new Response(null, { status: 500 })),
1200+
fetch: () => () => new Response(null, { status: 500 }),
12021201
});
12031202
await gateway.query({
12041203
shouldReturnErrors: true,

packages/plugins/opentelemetry/tests/utils.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
type TracerConfig,
2828
} from '@opentelemetry/sdk-trace-base';
2929
import { AsyncDisposableStack } from '@whatwg-node/disposablestack';
30+
import { fakePromise } from '@whatwg-node/promise-helpers';
3031
import { createSchema, createYoga, type GraphQLParams } from 'graphql-yoga';
3132
import { expect } from 'vitest';
3233
import { hive } from '../src/api';
@@ -182,11 +183,11 @@ export class MockSpanExporter implements SpanExporter {
182183
}
183184
shutdown() {
184185
this.reset();
185-
return Promise.resolve();
186+
return fakePromise();
186187
}
187188
forceFlush() {
188189
this.reset();
189-
return Promise.resolve();
190+
return fakePromise();
190191
}
191192
reset() {
192193
this.spans = [];
@@ -352,12 +353,12 @@ export class MockLogRecordExporter implements LogRecordExporter {
352353

353354
shutdown(): Promise<void> {
354355
this.reset();
355-
return Promise.resolve();
356+
return fakePromise();
356357
}
357358

358359
forceFlush(): Promise<void> {
359360
this.reset();
360-
return Promise.resolve();
361+
return fakePromise();
361362
}
362363

363364
reset() {

packages/pubsub/src/mem.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Repeater } from '@repeaterjs/repeater';
22
import { DisposableSymbols } from '@whatwg-node/disposablestack';
3-
import { type MaybePromise } from '@whatwg-node/promise-helpers';
3+
import { fakePromise, type MaybePromise } from '@whatwg-node/promise-helpers';
44
import { PubSub, PubSubListener, TopicDataMap } from './pubsub';
55

66
/** In-memory {@link PubSub} implementation. */
@@ -53,13 +53,14 @@ export class MemPubSub<M extends TopicDataMap = TopicDataMap>
5353
}
5454

5555
if (!listener) {
56-
return new Repeater<M[Topic], any, any>(async (push, stop) => {
56+
return new Repeater<M[Topic], any, any>((push, stop) => {
5757
listeners.set(push, stop);
58-
await stop;
59-
listeners.delete(push);
60-
if (listeners.size === 0) {
61-
this.#subscribers.delete(topic);
62-
}
58+
return stop.then(() => {
59+
listeners.delete(push);
60+
if (listeners.size === 0) {
61+
this.#subscribers.delete(topic);
62+
}
63+
});
6364
});
6465
}
6566

@@ -88,6 +89,6 @@ export class MemPubSub<M extends TopicDataMap = TopicDataMap>
8889
}
8990

9091
[DisposableSymbols.asyncDispose]() {
91-
return Promise.resolve(this.dispose());
92+
return fakePromise(this.dispose());
9293
}
9394
}

0 commit comments

Comments
 (0)