instructure / instructure/canvas-rce-api

Getting async error

Open
#2 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
22
Forks
39
PR merge metrics
No merged PRs in 30d

Description

I have canvas up and running and I am trying to add the RCE. Everything in canvas is working (seemingly) fine, but when I attempt to use RCE linking features I am getting this error in my browsers js console.

Failed to load http://rce.docker:3001/api/wikiPages?contextType=course&contextId=1: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://canvas.docker:3000' is therefore not allowed access. The response had HTTP status code 502. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I don't think this is a cors issue because I am getting this output form the RCE log.

canvas-rce_1  | App 39 output: [89892936-4cbb-4ad9-8169-787a675c1279] 127.0.0.1 - - [02/Oct/2018:21:06:43 +0000] "OPTIONS /api/wikiPages?contextType=course&contextId=1 HTTP/1.1" 204 - "http://canvas.docker:3000/courses/1/assignments/1/edit" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"
canvas-rce_1  | 172.23.0.1 - - [02/Oct/2018:21:06:43 +0000] "OPTIONS /api/wikiPages?contextType=course&contextId=1 HTTP/1.1" 204 0 "http://canvas.docker:3000/courses/1/assignments/1/edit" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"
canvas-rce_1  | App 39 output: (node:39) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'link' of undefined
canvas-rce_1  | App 39 output:     at parseBookmark (/usr/src/app/app/api/canvasProxy.js:32:35)
canvas-rce_1  | App 39 output:     at <anonymous>
canvas-rce_1  | App 39 output:     at process._tickCallback (internal/process/next_tick.js:188:7)
canvas-rce_1  | App 39 output: (node:39) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 6)

I probably have something misconfigured somewhere as I am just starting to get this settup, but I cannot determine from the above error what the missconfiguration is.

I am running the latest (as of 2nd Oct, 2018) RCE docker image. I am running everything locally with the intent of eventually running this in production. My docker-compose.yml is as follows.

version: '3'

services:
  # TODO use a custom redis based image that is a bit more hardedned.
  redis:
    image: redis:4.0-alpine
  # TODO use a custom postgres image that is a bit more hardened.
  db:
    image: postgres:9.5-alpine
    volumes:
      - ./tmp/db:/var/lib/postgresql/data
    # configure database access based on environment variables
    environment:
      - POSTGRES_USER=canvas
      - POSTGRES_PASSWORD=your_password
      - POSTGRES_DB=canvas,canvas_development,canvas_production,canvas_test

  canvas-lms: &LMS
    build:
      context: ./dockerfiles/canvas-lms
    command: bundle exec rails s -p 3000 -b '0.0.0.0'

    # which port should be accessible from the outside?
    ports:
      - "3000:3000"

    # start container once `db` service is up
    depends_on:
      - db
      - redis

    # `db` and `node` should be able to communicate
    links:
      - db
      - redis
      - canvas-rce

  # Delayed jobs
  jobs:
    <<: *LMS
    command: bundle exec script/delayed_job run
    links:
      - db
      - redis

    ports: []

  canvas-rce:
    image: instructure/canvas-rce-api:latest
    environment:
      - ECOSYSTEM_KEY
      - ECOSYSTEM_SECRET
      - FLICKR_API_KEY
      - YOUTUBE_API_KEY

    expose:
     - "80"

    ports:
      - "3001:80"

My canvas-lms dockerfile is simple enough, it sets up a production environment according to the prod documentation and copies in some custom configuration files. While it isn't based on the canvas-lms official docker image is accomplishes much the same thing.

I am running chrome, macos 10.13.6, Docker CE stable Version 18.06.1-ce-mac73 (26764)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with app/api/canvasProxy.js at parseBookmark, the stack-trace location, and review the provided docker-compose.yml for the RCE and Canvas service configuration. Reproduce the wikiPages request and trace why it returns 502 and produces the unhandled rejection; done means the linking request succeeds without that error.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, docker-compose, javascript
Domain
api, backend, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.