codesandbox / codesandbox-client

An online IDE for rapid web development
https://codesandbox.io
Other
13.03k stars 2.27k forks source link

Tasks do not run when visiting with sharing url (not logged in) #8533

Open schettn opened 1 month ago

schettn commented 1 month ago

🐛 bug report

Preflight Checklist

Description of the problem

How has this issue affected you? What are you trying to accomplish?

When accessing a CodeSandbox project through a sharing URL without being logged in, tasks that are supposed to run automatically do not execute as expected.

image

When accessing the same sandbox as my user, everything works fine. image

To Reproduce

Link to sandbox: https://codesandbox.io/p/github/getcronit/pylon-template/main?file=%2Fsrc%2Findex.ts%3A18%2C1

Link to repo: https://github.com/getcronit/pylon-template

Maybe related: https://github.com/codesandbox/codesandbox-client/issues/8442

Your Environment

Software Name/Version
Сodesandbox Latest
Browser Safari / Chrome
Operating System MacOS
filipelima18 commented 1 month ago

Hi @schettn. I was unable to reproduce the issue you described. Taking our public Docs repo as an example (https://codesandbox.io/p/github/codesandbox/docs/main), it opens the tasks and previews on startup both for logged-in and unauthenticated users.

I also tried to replicate this on the URL you provided but it seems that the start task is failing.

schettn commented 1 month ago

Mhm.. Do you have any idea why the start task does not fail when logged on? How can I debug this?

This is my tasks.json:

{
  // These tasks will run in order when initializing your CodeSandbox project.
  "setupTasks": [
    {
      "name": "Install Dependencies",
      "command": "bun install"
    }
  ],

  // These tasks can be run from CodeSandbox. Running one will open a log in the app.
  "tasks": {
    "Start": {
      "name": "Start",
      "command": "bun develop",
      "runAtStart": true,
      "preview": {
        "port": 3000
      }
    }
  }
}
schettn commented 1 month ago

Hi @filipelima18. I recorded a video that shows that it no longer works after I log out. I. have no idea what could be wrong. I would appreciate it if you could help me out on this!

https://github.com/user-attachments/assets/70843bcc-f21b-43f8-b86f-17857be3f865

filipelima18 commented 1 month ago

Hi @schettn. I shared this with the engineering team for analysis. Thank you for your patience while we figure out what might be causing this.

CompuIves commented 1 month ago

Hey! I've looked at the issue, and I believe this is happening because of some confusing behaviour in CodeSandbox itself (which I think we should fix). If you open a repo as an anonymous user, you open a different version than if you open it signed in (in your workspace). Because of this, the public version is not running the tasks.

However, I think that you are looking to share a template for other people to see and potentially fork, and for that we have a different functionality in CodeSandbox that's built for that purpose that should work in your case! If you use this URL:

http://codesandbox.io/p/devbox/github/getcronit/pylon-template/main?file=/src/index.ts:18,1

You will get a link back to a template that is anonymous, but stays synced with the GitHub repository. Everyone will see the same version, and they can fork it if they want to have their own version of it. We're working on revamping the import modal to make that distinction more clear. I hope this helps!

schettn commented 1 month ago

@CompuIves This makes sense!

Where did you get this URL from?

I thought that I had to get the sharing link. But the sharing link is not the devbox.

image

schettn commented 1 month ago

Ah I see. My project isn't a Devbox right?

image