Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,18 @@ 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 &&
!readEnv('KERNEL_SUPPRESS_BUN_WARNING')
) {
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',
);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is the combination of Bun and Playwright, right? If so I think we should be more forgiving and log a warning to that effect (instead of throwing) and also give users the option to turn off the warning, e.g.

"WARNING: if you are using Playwright with Bun you will not be able to connect over CDP: {link to GitHub issue}.
Turn off this warning with KERNEL_BUN_WARNING=off"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed!

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' }).",
Expand Down