From 89985e352e1dafaa34fba19eb18064e64307f6a4 Mon Sep 17 00:00:00 2001 From: Christian Glassiognon <63924603+heyglassy@users.noreply.github.com> Date: Tue, 12 Aug 2025 14:38:21 -0700 Subject: [PATCH 1/4] prevent users from using Kernel with Bun --- src/client.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/client.ts b/src/client.ts index 89509db..50997b2 100644 --- a/src/client.ts +++ b/src/client.ts @@ -187,6 +187,13 @@ export class Kernel { apiKey = readEnv('KERNEL_API_KEY'), ...opts }: ClientOptions = {}) { + // Check for Bun runtime in a way that avoids type errors if Bun is not defined + if (typeof globalThis !== 'undefined' && typeof (globalThis as any).Bun !== 'undefined' && (globalThis as any).Bun.version) { + throw new Errors.KernelError( + 'The Bun runtime is not supported. Please use a different runtime.', + ); + } + if (apiKey === undefined) { throw new Errors.KernelError( "The KERNEL_API_KEY environment variable is missing or empty; either provide it, or instantiate the Kernel client with an apiKey option, like new Kernel({ apiKey: 'My API Key' }).", From 745fc0f7627288ec89f9c5b2e2e66dd6c65e4436 Mon Sep 17 00:00:00 2001 From: Christian Glassiognon <63924603+heyglassy@users.noreply.github.com> Date: Tue, 12 Aug 2025 14:40:14 -0700 Subject: [PATCH 2/4] prettier --- src/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index 50997b2..48dfb3f 100644 --- a/src/client.ts +++ b/src/client.ts @@ -190,7 +190,7 @@ export class Kernel { // Check for Bun runtime in a way that avoids type errors if Bun is not defined if (typeof globalThis !== 'undefined' && typeof (globalThis as any).Bun !== 'undefined' && (globalThis as any).Bun.version) { throw new Errors.KernelError( - 'The Bun runtime is not supported. Please use a different runtime.', + "The Bun runtime is not supported. Please use a different runtime.", ); } From 80ec147fc5a768af6d64f876392246c2a2fa4e3b Mon Sep 17 00:00:00 2001 From: Christian Glassiognon <63924603+heyglassy@users.noreply.github.com> Date: Tue, 12 Aug 2025 14:44:08 -0700 Subject: [PATCH 3/4] fix lints --- src/client.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/client.ts b/src/client.ts index 48dfb3f..0147616 100644 --- a/src/client.ts +++ b/src/client.ts @@ -188,10 +188,12 @@ export class Kernel { ...opts }: ClientOptions = {}) { // Check for Bun runtime in a way that avoids type errors if Bun is not defined - if (typeof globalThis !== 'undefined' && typeof (globalThis as any).Bun !== 'undefined' && (globalThis as any).Bun.version) { - throw new Errors.KernelError( - "The Bun runtime is not supported. Please use a different runtime.", - ); + if ( + typeof globalThis !== 'undefined' && + typeof (globalThis as any).Bun !== 'undefined' && + (globalThis as any).Bun.version + ) { + throw new Errors.KernelError('The Bun runtime is not supported. Please use a different runtime.'); } if (apiKey === undefined) { From cfe990eb331b08ac0f702fa18d4e2730a5cd527c Mon Sep 17 00:00:00 2001 From: Christian Glassiognon <63924603+heyglassy@users.noreply.github.com> Date: Tue, 12 Aug 2025 16:21:54 -0700 Subject: [PATCH 4/4] change copy and functionality --- src/client.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/client.ts b/src/client.ts index 0147616..0da7c4c 100644 --- a/src/client.ts +++ b/src/client.ts @@ -191,9 +191,12 @@ export class Kernel { if ( typeof globalThis !== 'undefined' && typeof (globalThis as any).Bun !== 'undefined' && - (globalThis as any).Bun.version + (globalThis as any).Bun.version && + !readEnv('KERNEL_SUPPRESS_BUN_WARNING') ) { - throw new Errors.KernelError('The Bun runtime is not supported. Please use a different runtime.'); + loggerFor(this).warn( + 'The Bun runtime was detected. Playwright may have CDP connection issues, proceed with caution. Suppress this warning by setting the KERNEL_SUPPRESS_BUN_WARNING environment variable to true', + ); } if (apiKey === undefined) {