لا يمكنني تشغيل التضمين

Some further debugging findings:

I manually created a topic and replaced discourseEmbedUrl: 'http://localhost:3001/enlistments/<%= @enlistment.id %>' with topicId: 14 in my JavaScript snippet, and it loaded the comments. That suggests it’s not a CORS or X-Frame- issue, but (a) something to do with scraping, and (b) possibly an issue with how errors are handled whilst embedding.

To investigate the scraping issue, I visited a new page that I hadn’t tried to access before (and therefore no scraping should have been attempted on it). I watched my app’s rails console and loaded the page. I saw /enlistments/6 in the log once. I waited until the error message was thrown in the JavaScript console, by which point Discourse should have attempted to scrape it, but my app’s rails console did not show any other access attempt logs.

There were no errors in discourse’s /logs endpoint, nor any I could make out in discourse’s rails log.

I thought maybe Discourse couldn’t access my website, so I logged into the rails console on my discourse app and ran:

± |master U:3 ?:2 ✗| → rails c
Loading development environment (Rails 6.0.3.3)
[1] pry(main)> require "net/http"
=> false
[2] pry(main)> url = URI.parse("http://localhost:3001/enlistments/6")
=> #<URI::HTTP http://localhost:3001/enlistments/6>
[3] pry(main)> req = Net::HTTP.new(url.host, url.port)
=> #<Net::HTTP localhost:3001 open=false>
[4] pry(main)> res = req.request_head(url.path)
4=> #<Net::HTTPOK 200 OK readbody=true>
[5] pry(main)>

As I did that, I saw the access log in my app’s rails server. This confirmed Discourse can reach my app.

Now I’m thinking it must be an issue with sidekiq or job scheduling? :man_shrugging: I’m not sure how to debug that, though. I’ve never used sidekiq before.

I took another look through the redis data (using TablePlus, a database GUI that works with redis), and I’m seeing about 3 rows with a key of values like default:logster-env-96404aef1da0c422fc32e3bb82d85fbc and a value with values like

[
  {
    "hostname": "myhostname",
    "process_id": 7188,
    "application_version": "60bc38e6a8914a10341a32ff9909e69faa65ffef",
    "params": {
      "embed_url": "http: //localhost:3001/enlistments/11927"
    },
    "HTTP_HOST": "localhost:3000",
    "REQUEST_URI": "/embed/comments?embed_url=http%3A%2F%2Flocalhost%3A3001%2Fenlistments%2F11927",
    "REQUEST_METHOD": "GET",
    "HTTP_USER_AGENT": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.60 Safari/537.36",
    "HTTP_ACCEPT": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
    "HTTP_REFERER": "http://localhost:3000/embed/comments?embed_url=http%3A%2F%2Flocalhost%3A3001%2Fenlistments%2F11927",
    "time": 1606253787041
  }
]

the type is LIST and ttl is -1. I guess that means the job is getting initiated?

I’ve poked around in /sidekiq but I see no mention of this job nor any kind of queue called RetrieveTopic :frowning:

Definitely narrowing things down but could use a hand if anything comes to mind!