Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local Development Server crashing upon clicking Run Code #80

Closed
prayutsu opened this issue Mar 2, 2022 · 15 comments
Closed

Local Development Server crashing upon clicking Run Code #80

prayutsu opened this issue Mar 2, 2022 · 15 comments

Comments

@prayutsu
Copy link

prayutsu commented Mar 2, 2022

Describe the bug
A clear and concise description of what the bug is.

Add a code snippet in editor.

To Reproduce
Steps to reproduce the behavior:

  1. Join a public room on a local development server.
  2. Write a code snippet in the editor.
  3. Click run code.
  4. Notice the server is crashed and the loading continues in the output section.

Expected behavior
The app shouldn't crash and the program should compile successfully.

Screenshots
If applicable, add screenshots to help explain your problem.

Screenshot 2022-03-02 at 10 55 35 PM

Screenshot 2022-03-02 at 11 00 05 PM

Desktop (please complete the following information):

  • OS: [e.g. iOS] Mac os
  • Browser [e.g. chrome, safari] Brave
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

@prayutsu
Copy link
Author

prayutsu commented Mar 2, 2022

@Rishabh-malhotraa I set up the project again and I am now able to fetch the problems from codeforces and leetcode problems list is also available, messaging feature also seems fine but the code is not getting compiled.
Here is a screenshot of the console errors -
Screenshot 2022-03-02 at 11 03 44 PM

P.S - I haven't created any .env files this time as I have followed these instructions.

@prayutsu prayutsu changed the title Server crashing upon clicking Run Code Local Development Server crashing upon clicking Run Code Mar 2, 2022
@Rishabh-malhotraa
Copy link
Owner

Rishabh-malhotraa commented Mar 2, 2022

You should not need to create a .env file as config.keys add default values if .env file is not created, you would require to create a .env file if you need to add your oauth token credentials etc.

  • You need to get your JDOODLE api keys to execute code(a free account is limited to 200 executions per day).

image

(For adding jdoodle credentials you need to create and .env file)

JDOODLE_CLIENTID=get_your_key
JDOOLDE_CLIENTSECRET=get_your_key
  • Change export const JDOODLE_URL = process.env.JDOODLE_URL || "https://api.jdoodle.com/v1/execute"; to export const JDOODLE_URL = process.env.JDOODLE_URL || "https://api.jdoodle.com/v1"; in config.keys
    I fixed this issue you can just pull it from main

@prayutsu
Copy link
Author

prayutsu commented Mar 6, 2022

@Rishabh-malhotraa I made the changes you mentioned -

  1. Created a .env file
  2. Put JDOODLE_SECRETS in it.
  3. Updated JDOODLE_URL (took a pull from main).

But the app is getting crashed when I am clicking on run code button.
Screenshot 2022-03-06 at 10 14 56 PM
Screenshot 2022-03-06 at 10 15 03 PM

@prayutsu
Copy link
Author

prayutsu commented Mar 6, 2022

Why it is returning an unauthorized status code?

@Rishabh-malhotraa
Copy link
Owner

Why it is returning an unauthorized status code?

I you are getting unauthorized, that means your tokens are incorrect, can you recheck your tokens, you require two of them

@prayutsu
Copy link
Author

prayutsu commented Mar 6, 2022

@Rishabh-malhotraa I doubted same, and I therefore checked the secrets 4-5 times.

My .env file

JDOODLE_CLIENTID=832e180ceafc5633a65a66e23fb22ad4
JDOOLDE_CLIENTSECRET=e310c26040828fdfa6eb3958cbd205310095937f2d552ea0e3e37b12a0ea2e2b

This is what I get from JDOODLE credentials tab -
Client ID
832e180ceafc5633a65a66e23fb22ad4
Client Secret
e310c26040828fdfa6eb3958cbd205310095937f2d552ea0e3e37b12a0ea2e2b

I believe that they both are the same.

@prayutsu
Copy link
Author

prayutsu commented Mar 6, 2022

I also tried refreshing credentials and getting a new client secret but the error remains the same.

@Rishabh-malhotraa
Copy link
Owner

I think it's your still your credential keys issue you can try getting your keys from a different account

for now, you can use these keys, but I'll refresh them tomorrow so you would not be able to use them after tomorrow, so maybe try getting the keys from a different account.

JDOODLE_CLIENTID=da358ecadea106b681e17e6dd1194863
JDOOLDE_CLIENTSECRET=7b69d6ce85668cb6fe5dbd61d37433bf3ffe31c14fed906833faad7e2593f5ca

@prayutsu
Copy link
Author

prayutsu commented Mar 6, 2022

Unfortunately, I am getting the same error even if I tried the credentials provided above. But the status code is 404 this time.
Screenshot 2022-03-02 at 10 55 35 PM

Upon trying again, it resulted in a 401 status code again.
Screenshot 2022-03-06 at 11 53 37 PM

@Rishabh-malhotraa
Copy link
Owner

you need to restart the server once you update the env file

@prayutsu
Copy link
Author

prayutsu commented Mar 6, 2022

you need to restart the server once you update the env file

Actually, I did restart the server several times.
I took a few snapshots of the console. Maybe it can help to identify the problem.
Screenshot 2022-03-07 at 12 15 17 AM

Screenshot 2022-03-07 at 12 14 45 AM

@prayutsu
Copy link
Author

prayutsu commented Mar 6, 2022

Also, one more thing to note is that if I click run code on empty code, it doesn't throw any error. That means -

We are reaching out to some part of the the /execute endpoint -

router.post("/execute", async (req, res) => {
  const { script, language, stdin } = req.body;
  if (!language || !script) {
    return res.status(200).json({
      message: "Code should not be empty and Language undefined",
    });
  }

  const response = await axios({
    method: "POST",
    url: `${JDOODLE_URL}/execute`,
    data: {
      script: script,
      stdin: stdin,
      language: getLanguage[language],
      versionIndex: getLanguageVersion[language],
      clientId: JDOODLE.clientID,
      clientSecret: JDOODLE.clientSecret,
    },
    responseType: "json",
  });
  res.json(response.data);
});

Screenshot 2022-03-07 at 12 23 50 AM

@prayutsu
Copy link
Author

@Rishabh-malhotraa Did you get a chance to investigate further?

@Rishabh-malhotraa
Copy link
Owner

Can you try running on incognito and maybe do a reinstall of Caucus with latest commit(don't add any env file in the clean install as the config file contains the credentials now)

@prayutsu
Copy link
Author

Can you try running on incognito and maybe do a reinstall of Caucus with the latest commit(don't add any env file in the clean install as the config file contains the credentials now)

Screenshot 2022-03-11 at 10 41 59 PM

This finally worked. Thanks, @Rishabh-malhotraa for helping me set up the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants