Link

Common Issues

  1. api check <taskname> Error Codes
    1. Error #1: Task does not exist
    2. Error #2: Your command exited early or was not long-running
    3. Error #3: Your API did not start on the expected port
    4. Error #4: Could not start Optic proxy on baseUrl

api check <taskname> Error Codes

Error #1: Task does not exist

If you receive this error, it means the taskname does not exist in your optic.yml.

  1. If you have an optic.yml file, make sure that it
    • contains valid yaml
    • has a task defined matching the taskname you are checking ie my-task
      name: Test API
      tasks:
        my-task:
          command: npm run server-start
          baseUrl: http://localhost:3005
      
  2. If you do not have an optic.yml file, add Optic to your project by running api init

Error #2: Your command exited early or was not long-running

The command provided in your optic.yml file exited before Optic could start.

It MUST:

  • Start a long-running process (your API) that stays running until exited
  • Be runnable from the same directory as the optic.yml file w/o any special permissions
  1. Try running the command manually from your current directory to make sure it starts your API.
    • If this is not the right command for Optic to start your API, update the one in the optic.yml file and try again
    • If your command starts the server in the background (Docker detach style), you may need to choose another command to use Optic at this time.

Error #3: Your API did not start on the expected port

Every time you run api start, Optic assigns your API a random port to bind to. If you get this error, it means that your command runs, but the API is not starting on the $OPTIC_API_PORT within 25 seconds of Optic running your command.

  1. Make sure you updated your start command to include $OPTIC_API_PORT
    • For example, rails -s becomes rails -s --port $OPTIC_API_PORT
  2. Or Make sure your code has been updated to bind to whatever port Optic provides via the $OPTIC_API_PORT environment variable.

Language specific guides for completing this step can be found here

Error #4: Could not start Optic proxy on baseUrl

Optic was unable to start its proxy on the baseUrl you specified. This is likely caused by one of the following:

  1. An instance from before you set up Optic is still running
  2. Another process is bound to the port you selected
  3. Binding to the port you chose for your baseUrl requires higher pillages.