Skip to content
Merged
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@
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) {

Check failure on line 191 in src/client.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `typeof·globalThis·!==·'undefined'·&&·typeof·(globalThis·as·any).Bun·!==·'undefined'·&&·(globalThis·as·any).Bun.version` with `⏎······typeof·globalThis·!==·'undefined'·&&⏎······typeof·(globalThis·as·any).Bun·!==·'undefined'·&&⏎······(globalThis·as·any).Bun.version⏎····`
throw new Errors.KernelError(

Check failure on line 192 in src/client.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎········'The·Bun·runtime·is·not·supported.·Please·use·a·different·runtime.',⏎······` with `'The·Bun·runtime·is·not·supported.·Please·use·a·different·runtime.'`
'The Bun runtime is not supported. Please use a different runtime.',
);
}

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
Loading