clerk/javascript

Having a complex Astro config throws "Converting circular structure to JSON" when using Clerk components.

ernestoalejo opened this issue · 5 comments

Preliminary Checks

Reproduction

https://stackblitz.com/edit/github-rdq1n6?file=astro.config.mjs

Publishable key

pk_test_YW1hemVkLXR1cmtleS02Mi5jbGVyay5hY2NvdW50cy5kZXYk

Description

Steps to reproduce:

  1. Initialize a new Astro project with Vue.
  2. Add Clerk with the official quickstart: https://clerk.com/docs/quickstarts/astro

If the vue plugin, or any other complex enough config, is added before the Clerk plugin runs and reads the config then a Converting circular structure to JSON throws when trying to use the components.

This occurs because the Astro config is not guaranteed to be JSON serializable here:

export const astroConfig = ${JSON.stringify(astroConfig)};

This also means that the plugin sees an incomplete vision of the config object depending on when it runs so it's not useful anyway.

From the reproduction:

export default defineConfig({
  adapter: node({ mode: 'standalone' }),
  output: 'server',

  // Works
  integrations: [clerk()],

  // Works:
  // integrations: [clerk(), vue()],

  // Doesn't work, circular structure:
  // integrations: [vue(), clerk()],
});

Expected behavior:

It works with any Astro config file.

Actual behavior:

image

Environment

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @astrojs/node: ^8.3.3 => 8.3.3 
    @astrojs/vue: ^4.5.0 => 4.5.0 
    @clerk/astro: ^1.2.6 => 1.2.6 
    astro: ^4.15.4 => 4.15.4 
    vue: ^3.4.38 => 3.5.3

Hi, thanks for reporting this and providing good reproduction. I can confirm this issue on my end as well when I put the clerk integration as the last item in the integrations array:

Screenshot 2024-09-13 at 9 29 05 AM

A PR is opened fixing this one <3

Apologies for the reopening/closing but the PR fix is merged and should be available in the next release

Still having a bug with the current release. A fix was to reverting back to version 1.0.5.

@bbagherian the fix for this will be available in the next release (1.3.3)

@bbagherian @ernestoalejo These changes were released a few hours ago! I'm going to close this issue out, but feel free to re-open if you're still having issues. Thanks!