openai-quickstart-node icon indicating copy to clipboard operation
openai-quickstart-node copied to clipboard

Internal Server Error

Open Sheikh-JamirAlam opened this issue 2 years ago • 8 comments

I am running the project locally but whenever I tried clicking "Generate names" but it shows this error. Anyone knows how to fix this? image

Sheikh-JamirAlam avatar Dec 09 '22 18:12 Sheikh-JamirAlam

I'm getting exactly the same thing... did you get anywhere with your issue @Sheikh-JamirAlam

kwello-alexhicks avatar Dec 10 '22 07:12 kwello-alexhicks

Seems like my quota has exceeded for making request to the API. No idea how to work around it though. @kwello-alexhicks

Sheikh-JamirAlam avatar Dec 10 '22 08:12 Sheikh-JamirAlam

My issue doesn't appear to be related to the API, reviewing the generate Response is the same as yours that it is not a valid JSON reponse

{ "props": { "pageProps": { "statusCode": 500 } }, "page": "/_error", "query": { "__NEXT_PAGE": "/api/generate" }, "buildId": "development", "isFallback": false, "err": { "name": "Error", "message": "Request failed with status code 401", "stack": "Error: Request failed with status code 401\n at createError (/Users/XXXXX/openai-quickstart-node/node_modules/axios/lib/core/createError.js:16:15)\n at settle (/Users/XXXXX/openai-quickstart-node/node_modules/axios/lib/core/settle.js:17:12)\n at IncomingMessage.handleStreamEnd (/Users/XXXXX/openai-quickstart-node/node_modules/axios/lib/adapters/http.js:322:11)\n at IncomingMessage.emit (node:events:525:35)\n at IncomingMessage.emit (node:domain:489:12)\n at endReadableNT (node:internal/streams/readable:1359:12)\n at process.processTicksAndRejections (node:internal/process/task_queues:82:21)" }, "gip": true, "scriptLoader": [] }

kwello-alexhicks avatar Dec 10 '22 08:12 kwello-alexhicks

@Sheikh-JamirAlam Ok, so i opened a new terminal, ran

npm run build npm run start npm run dev

Then I can successfully run the application on new port 3001

Bit odd, or missing step in the documentation?

kwello-alexhicks avatar Dec 10 '22 08:12 kwello-alexhicks

Yes the API is not generating a JSON file. Do you run the "npm run start" and "npm run dev" commands in different terminals? @kwello-alexhicks

Sheikh-JamirAlam avatar Dec 10 '22 08:12 Sheikh-JamirAlam

@Sheikh-JamirAlam correct order, from the same terminal (after killing the faulty terminal) is:

npm run start npm run build npm run dev

This now works successfully for me

kwello-alexhicks avatar Dec 10 '22 16:12 kwello-alexhicks

@kwello-alexhicks Now I am facing with this error. I ran npm run build and it still is the same. Can you show your terminal if thats ok? image

Sheikh-JamirAlam avatar Dec 10 '22 18:12 Sheikh-JamirAlam

Here is a clue whats going on:

response: { status: 401, statusText: 'Unauthorized', headers: { date: 'Mon, 12 Dec 2022 19:14:53 GMT', 'content-type': 'application/json; charset=utf-8', 'content-length': '475', connection: 'close', vary: 'Origin', 'x-request-id': '670473a8d453eedfefc8f0d9e3cc6c32', 'strict-transport-security': 'max-age=15724800; includeSubDomains' },

sixTheDave avatar Dec 12 '22 19:12 sixTheDave

@ Sheikh-JamirAlam: Took me a while but my similar issue of errors was that I put my API Key in ".env.example" when it of course needed to be in ".env" instead.

frank-evans avatar Dec 16 '22 21:12 frank-evans

same situation, thx

AlbaChloe avatar Dec 19 '22 06:12 AlbaChloe

same situation, thx

Thanks. Did the same mistake. Added the .env file with API key fixed the issue.

Sanan4li avatar Dec 22 '22 09:12 Sanan4li

@Sanan4li Can you tell me which commands you are using to run it locally?

Sheikh-JamirAlam avatar Dec 23 '22 04:12 Sheikh-JamirAlam

Screen Shot 2022-12-23 at 10 21 40 PM

I'm still getting the issue even after running:

npm run start npm run build npm run dev

@kwello-alexhicks is this still working on your end?

@Sheikh-JamirAlam are you still having trouble?

neocybereth avatar Dec 23 '22 09:12 neocybereth

@jeevnayak @schnerd would either of you happen to know any fixes for this perchance?

neocybereth avatar Dec 23 '22 09:12 neocybereth

Screen Shot 2022-12-23 at 10 21 40 PM

I'm still getting the issue even after running:

npm run start npm run build npm run dev

@kwello-alexhicks is this still working on your end?

@Sheikh-JamirAlam are you still having trouble?

no need to use command line, just check your env filename, the repo's original env filename is ".env.example", rename it with ".env" will work : )

AlbaChloe avatar Dec 23 '22 09:12 AlbaChloe

@AlbaChloe ive already done that, but no dice. Seems the 500 errors coming from elsewhere

neocybereth avatar Dec 23 '22 11:12 neocybereth

@neocybereth Yeah same, its not because of the .env file. As the error shows the API is returning a HTML file which was supposed to be a json. @AlbaChloe Is it working for you locally?

Sheikh-JamirAlam avatar Dec 23 '22 11:12 Sheikh-JamirAlam

image image @Sheikh-JamirAlam yep, my local file works fine after I change the filename to ".env", and before that, I got the same error @neocybereth sorry, maybe elsewhere I don't know, hope others can help you

AlbaChloe avatar Dec 23 '22 12:12 AlbaChloe

@AlbaChloe Did you maybe change the dependency versions or it worked just like that?

Sheikh-JamirAlam avatar Dec 23 '22 12:12 Sheikh-JamirAlam

@Sheikh-JamirAlam nope, I've never changed the dependencies, just run "npm install" to install the requirements

AlbaChloe avatar Dec 23 '22 12:12 AlbaChloe

I added some error handling logic (see #30) which should surface error messages returned by the API or due to misconfigured environment variables.

@neocybereth want to pull the latest version and give it a try?

schnerd avatar Dec 24 '22 01:12 schnerd

Yup, will do that now!

neocybereth avatar Dec 24 '22 01:12 neocybereth

Screen Shot 2022-12-24 at 2 18 20 PM

Welp seems that did the trick now @schnerd ..thank you!

neocybereth avatar Dec 24 '22 01:12 neocybereth

👍

I'm going to close this issue for now – the frontend should be surfacing more detailed error messages. If anyone continues to see errors where it's unclear how to resolve them, please feel free to open a separate issue!

schnerd avatar Dec 24 '22 17:12 schnerd