Skip to content

Commit bba59a6

Browse files
authored
Merge pull request #38 from onkernel/christian/prevent_bun_run
prevent users from using Kernel with Bun
2 parents 3fd6a3e + cfe990e commit bba59a6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/client.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,18 @@ export class Kernel {
187187
apiKey = readEnv('KERNEL_API_KEY'),
188188
...opts
189189
}: ClientOptions = {}) {
190+
// Check for Bun runtime in a way that avoids type errors if Bun is not defined
191+
if (
192+
typeof globalThis !== 'undefined' &&
193+
typeof (globalThis as any).Bun !== 'undefined' &&
194+
(globalThis as any).Bun.version &&
195+
!readEnv('KERNEL_SUPPRESS_BUN_WARNING')
196+
) {
197+
loggerFor(this).warn(
198+
'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',
199+
);
200+
}
201+
190202
if (apiKey === undefined) {
191203
throw new Errors.KernelError(
192204
"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' }).",

0 commit comments

Comments
 (0)