instructure / canvas-lms

The open LMS by Instructure, Inc.
https://github.com/instructure/canvas-lms/wiki
GNU Affero General Public License v3.0
5.58k stars 2.48k forks source link

Unhandled Promise Rejection: Canvas failed to connect to rich content editor docker #1478

Open srdurai opened 5 years ago

srdurai commented 5 years ago

Summary:

Canvas fails to connect to canvas-rce-api-host. As a result, wiki side-bar have disabled links and "Loading failed" messages.

Steps to reproduce:

git describe --tags
release/2019-06-22.25-11498-gbde65343ed

Running latest canvas-rce-api docker image. Command used to start docker: sudo docker run -d -e ECOSYSTEM_KEY="key" -e ECOSYSTEM_SECRET="key" -e NODE_TLS_REJECT_UNAUTHORIZED=1 -e STATSD_PORT=8125 -e STATSD_HOST=127.0.0.1 -p 3000:80 instructure/canvas-rce-api:latest

Front end encrypted with nginx. nginx conf:

server {
    listen 3001 ssl;
    ssl_certificate /etc/ssl/certs/apache-selfsigned.crt;
    ssl_certificate_key /etc/ssl/private/apache-selfsigned.key;
    server_name canvas-server.com;

  location / {
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $http_host;
          proxy_set_header X-Forwarded_Proto $scheme;
          proxy_redirect off;

          proxy_pass http://localhost:3000;
          proxy_read_timeout 300s;
          proxy_send_timeout 300s;
  }
}
curl -k https://localhost:3001
Hello, from RCE Service

Also tried with a separate server configured for canvas rce docker. Same error.

curl -k https://dbserver:3001
Hello, from RCE Service

Expected behavior:

Wiki side bar loads without error messages.

Actual behavior:

Error from browser using "inspect element":

[Error] A server with the specified hostname could not be found.
[Error] Fetch API cannot load https://dbserver:3001/api/session due to access control checks.
[Error] Failed to load resource: A server with the specified hostname could not be found. (session, line 0)
[Error] A server with the specified hostname could not be found.
[Error] Fetch API cannot load https://dbserver:3001/api/folders?contextType=course&contextId=1 due to access control checks.
[Error] Failed to load resource: A server with the specified hostname could not be found. (folders, line 0)
[Error] Unhandled Promise Rejection: Error: Failed to fetch from the canvas-rce-api.
        Did you forget to start it or configure it?
        Details can be found at https://github.com/instructure/canvas-rce-api

    (anonymous function) (canvas-rce-old-async-chunk-c-a392327795.js:9247:326)
    promiseReactionJob

Additional notes:

srdurai commented 5 years ago

Error from Firefox:

Strict-Transport-Security: The connection to the site is untrustworthy, so the specified header was ignored.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://dbserver:3001/api/session. (Reason: CORS request did not succeed).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://dbserver:3001/api/folders?contextType=course&contextId=1. (Reason: CORS request did not succeed).

Error: Failed to fetch from the canvas-rce-api. Did you forget to start it or configure it? Details can be found at https://github.com/instructure/canvas-rce-api

srdurai commented 5 years ago

Found this error from docker. Not sure if this is still a valid ticket or it should go to RCE API.


172.17.0.1 - - [22/Jul/2019:14:22:53 +0000] "GET /api/folders?contextType=course HTTP/1.0" 499 0 "-" "curl/7.58.0"
App 41 output: [2a7626ef-b1a0-47c1-99bd-0bab9e9bf11d] 127.0.0.1 - - [22/Jul/2019:14:22:53 +0000] "GET /api/folders?contextType=course HTTP/1.1" - - "-" "curl/7.58.0"
App 41 output: (node:41) UnhandledPromiseRejectionWarning: RequestError: Error: self signed certificate
App 41 output:     at new RequestError (/usr/src/app/node_modules/request-promise-core/lib/errors.js:14:15)
App 41 output:     at Request.plumbing.callback (/usr/src/app/node_modules/request-promise-core/lib/plumbing.js:87:29)
App 41 output:     at Request.RP$callback [as _callback] (/usr/src/app/node_modules/request-promise-core/lib/plumbing.js:46:31)
App 41 output:     at self.callback (/usr/src/app/node_modules/request/request.js:185:22)
App 41 output:     at Request.emit (events.js:189:13)
App 41 output:     at Request.onRequestError (/usr/src/app/node_modules/request/request.js:881:8)
App 41 output:     at ClientRequest.emit (events.js:189:13)
App 41 output:     at TLSSocket.socketErrorListener (_http_client.js:392:9)
App 41 output:     at TLSSocket.emit (events.js:189:13)
App 41 output:     at emitErrorNT (internal/streams/destroy.js:82:8)
App 41 output:     at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
App 41 output:     at process._tickCallback (internal/process/next_tick.js:63:19)
App 41 output: (node:41) 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: 2)
eschiebel commented 5 years ago

Not handling the rejected promise is clearly a problem, but the CORS rejection should not have happened. Requests to the RCE (http://dbserver:3001/) should have responded with an Access-Control-Allow-Origin header permitting access from canvas. I'm not knowledgeable about how docker might impact the URI, but the api response headers would be a good place to start.

Aetherus commented 5 years ago

I found that the rce sidebar is trying to call /api/wikiPages?contextType=course&contextId=1, which does not exist (missing /v1, the cases are all wrong). Is the URL correctly built?

dgilperez commented 3 years ago

@Aetherus I found the same exact problem, using latest stable version. RCE feature is disabled. Did you find a solution?

dqcuong93 commented 3 years ago

Hi, I have the same issue. Did you have a solution for this? Thank you.

dgilperez commented 3 years ago

I ended up installing RCE, setting it up, then marking it as "disabled" feature in the account features section ... and all works. Very weird to say the least. But it works 🤷 Hope it helps @dqcuong93

vidocq1102 commented 2 years ago

Hi, I have the same issue. Did you have a solution for this? Thank you.

Hi dqccuong93 are you resolve this problem?