a16z-infra / ai-town

A MIT-licensed, deployable starter kit for building and customizing your own version of AI town - a virtual town where AI characters live, chat and socialize.
https://convex.dev/ai-town
MIT License
7.39k stars 678 forks source link

Unhandled Runtime Error Error: Call Stack o._fetch async H.create #105

Open medraud94private opened 1 year ago

medraud94private commented 1 year ago

We've encountered a runtime issue with our web application which seems to be related to the @clerk/clerk-js library.

Error encountered: Unhandled Runtime Error Relevant functions: o._fetch and H.create Error location: https://suited-cicada-78.clerk.accounts.dev/npm/@clerk/clerk-js@4/dist/clerk.browser.js While the precise root cause is not immediately clear, it appears there might be issues in the data retrieval process within the o._fetch function or during data creation in H.create.

Could you please investigate further? Additionally, it might be helpful to consult the library's documentation or community for potential solutions. 스크린샷 2023-08-17 오후 4 00 00

Michael-A-Costa commented 1 year ago

I have the same issue. I wanted to get this set up before paying for an OpenAI subscription, could that be causing issues? Here is my console output if that helps.

PS C:\Users\pokes\ai-town> npm run dev

> ai-town@0.0.0 dev
> npm-run-all dev:init --parallel dev:frontend dev:backend

> ai-town@0.0.0 dev:init
> convex dev --run init --until-success

✔ 12:29:00 Convex functions ready! (3.58s)
✔ Finished running function "init"
'*************'

> ai-town@0.0.0 dev:frontend
> next dev

> ai-town@0.0.0 dev:backend
> convex dev

- info Loaded env from C:\Users\pokes\ai-town\.env.local
- warn You have enabled experimental feature (serverActions) in next.config.js.
- warn Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.

- ready started server on [::]:3000, url: http://localhost:3000
⠙ Preparing Convex functions...
⠼ Preparing Convex functions...
⠴ Checking for index or schema changes...
⠇ Backfilling indexes and checking that documents match your schema...
⠙ Backfilling indexes and checking that documents match your schema...
- info Loaded env from C:\Users\pokes\ai-town\.env.local
⠸ Backfilling indexes and checking that documents match your schema...
⠧ Backfilling indexes and checking that documents match your schema...
✔ 12:29:05 Convex functions ready! (3.58s)
- event compiled client and server successfully in 1493 ms (2242 modules)
- wait compiling...
- event compiled successfully in 215 ms (902 modules)
- error node_modules\@pixi\sound\lib\utils\supported.mjs (27:0) @ validateFormats
- error ReferenceError: document is not defined
    at __webpack_require__ (C:\Users\pokes\ai-town\.next\server\webpack-runtime.js:33:43)
    at __webpack_require__ (C:\Users\pokes\ai-town\.next\server\webpack-runtime.js:33:43)
    at __webpack_require__ (C:\Users\pokes\ai-town\.next\server\webpack-runtime.js:33:43)
    at __webpack_require__ (C:\Users\pokes\ai-town\.next\server\webpack-runtime.js:33:43)
    at eval (./src/components/MusicButton.tsx:11:69)
    at (ssr)/./src/components/MusicButton.tsx (C:\Users\pokes\ai-town\.next\server\app\page.js:6304:1)
    at __webpack_require__ (C:\Users\pokes\ai-town\.next\server\webpack-runtime.js:33:43)
null
- wait compiling /favicon.ico/route (client and server)...
- event compiled client and server successfully in 227 ms (2270 modules)
- error node_modules\@pixi\sound\lib\utils\supported.mjs (27:0) @ validateFormats
- error ReferenceError: document is not defined
    at __webpack_require__ (C:\Users\pokes\ai-town\.next\server\webpack-runtime.js:33:43)
    at __webpack_require__ (C:\Users\pokes\ai-town\.next\server\webpack-runtime.js:33:43)
    at __webpack_require__ (C:\Users\pokes\ai-town\.next\server\webpack-runtime.js:33:43)
    at __webpack_require__ (C:\Users\pokes\ai-town\.next\server\webpack-runtime.js:33:43)
    at eval (./src/components/MusicButton.tsx:11:69)
    at (ssr)/./src/components/MusicButton.tsx (C:\Users\pokes\ai-town\.next\server\app\page.js:6304:1)
    at __webpack_require__ (C:\Users\pokes\ai-town\.next\server\webpack-runtime.js:33:43)
null

Edit: I got my OpenAI subscription set up but I still have issues I have my Convex set up like this CLERK_ISSUER_URL = https://abc-def-123.clerk.accounts.dev/.well-known/jwks.json and I get this error POST https://abc-def-123.clerk.accounts.dev/v1/client/sessions/sess_***/tokens/convex?_clerk_js_version=4.53.0&__dev_session=**** 404 which leads to some exceptions clerk.browser.js:2 Uncaught (in promise) Error at o._fetch (clerk.browser.js:2:77218) at async H.create (clerk.browser.js:2:107563)

Kevin-free commented 1 year ago

@medraud94private @Michael-A-Costa I also encounter this problem, do you know how to solve it?

I followed the tutorial "create a new Convex Template" and "Copy the JWKS endpoint URL" in Clerk.

The environment variable CLERK_ISSUER_URL=https://communal-moth-26.clerk.accounts.dev/.well-known/jwks.json has been set in convex

.env.local has:

CLERK_ISSUER_URL=https://communal-moth-26.clerk.accounts.dev/.well-known/jwks.json
> npm run dev

> ai-town@0.0.0 dev
> npm-run-all dev:init --parallel dev:frontend dev:backend

> ai-town@0.0.0 dev:init
> convex dev --run init --until-success

✔ 12:12:34 Convex functions ready! (10.64s)
✔ Finished running function "init"
'4ccewghnza6p57s589tvrhgd9j4ee0r'

> ai-town@0.0.0 dev:backend
> convex dev

> ai-town@0.0.0 dev:frontend
> next dev

- ready started server on 0.0.0.0:3000, url: http://localhost:3000
- info Loaded env from /Users/***/1619-ai-town/.env.local
- warn You have enabled experimental feature (serverActions) in next.config.js.
- warn Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.

⠴Preparing Convex functions...
⠇ Preparing Convex functions...  
⠙ Preparing Convex functions...
✔ 12:12:46 Convex functions ready! (7.15s)
- wait compiling /src/middleware (client and server)...
- event compiled successfully in 218 ms (244 modules)
- wait compiling /page (client and server)...
- event compiled client and server successfully in 2.4s (2411 modules)
- wait compiling...
- event compiled successfully in 132 ms (999 modules)

Running error:

Unhandled Runtime Error
Error:

Call Stack
o._fetch
https://communal-moth-26.clerk.accounts.dev/npm/@clerk/clerk-js@4/dist/clerk.browser.js (2:77243)
async H. create
https://communal-moth-26.clerk.accounts.dev/npm/@clerk/clerk-js@4/dist/clerk.browser.js (2:107743)
image image image
Kevin-free commented 1 year ago

When I update the project, and update npm, I get another error 🥹

Unhandled Runtime Error
Error: Clerk: auth() was called but it looks like you aren't using `authMiddleware` in your middleware file. Please use `authMiddleware` and make sure your middleware matcher is configured correctly and it matches this route or page. See https https://clerk.com/docs/quickstarts/get-started-with-nextjs
> npm version
{
   'ai-town': '0.0.0',
   npm: '9.8.1',
   node: '18.0.0',
   v8: '10.1.124.8-node.13',
   uv: '1.43.0',
   zlib: '1.2.11',
   brotli: '1.0.9',
   ares: '1.18.1',
   modules: '108',
   nghttp2: '1.47.0',
   napi: '8',
   llhttp: '6.0.4',
   openssl: '3.0.2+quic',
   cldr: '41.0',
   icu: '71.1',
   tz: '2022a',
   unicode: '14.0',
   ngtcp2: '0.1.0-DEV',
   nghttp3: '0.1.0-DEV'
}
image
Kevin-free commented 1 year ago

@medraud94private @Michael-A-Costa I also encounter this problem, do you know how to solve it?

I followed the tutorial "create a new Convex Template" and "Copy the JWKS endpoint URL" in Clerk.

The environment variable CLERK_ISSUER_URL=https://communal-moth-26.clerk.accounts.dev/.well-known/jwks.json has been set in convex

.env.local has:

CLERK_ISSUER_URL=https://communal-moth-26.clerk.accounts.dev/.well-known/jwks.json
> npm run dev

> ai-town@0.0.0 dev
> npm-run-all dev:init --parallel dev:frontend dev:backend

> ai-town@0.0.0 dev:init
> convex dev --run init --until-success

✔ 12:12:34 Convex functions ready! (10.64s)
✔ Finished running function "init"
'4ccewghnza6p57s589tvrhgd9j4ee0r'

> ai-town@0.0.0 dev:backend
> convex dev

> ai-town@0.0.0 dev:frontend
> next dev

- ready started server on 0.0.0.0:3000, url: http://localhost:3000
- info Loaded env from /Users/***/1619-ai-town/.env.local
- warn You have enabled experimental feature (serverActions) in next.config.js.
- warn Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.

⠴Preparing Convex functions...
⠇ Preparing Convex functions...  
⠙ Preparing Convex functions...
✔ 12:12:46 Convex functions ready! (7.15s)
- wait compiling /src/middleware (client and server)...
- event compiled successfully in 218 ms (244 modules)
- wait compiling /page (client and server)...
- event compiled client and server successfully in 2.4s (2411 modules)
- wait compiling...
- event compiled successfully in 132 ms (999 modules)

Running error:

Unhandled Runtime Error
Error:

Call Stack
o._fetch
https://communal-moth-26.clerk.accounts.dev/npm/@clerk/clerk-js@4/dist/clerk.browser.js (2:77243)
async H. create
https://communal-moth-26.clerk.accounts.dev/npm/@clerk/clerk-js@4/dist/clerk.browser.js (2:107743)

image image image

I know how to solve it, the name of JWT Templates in clerk should be consistent with the Application ID in convex (I don’t know how to modify Application ID in convex, and why the default is convex)

image

image

image
arfazhxss commented 6 months ago

@jamwt @bcjordan the issue seems to have been resolved. I have encountered this exact issue and have fixed it through this thread. I think this issue can be closed.