Failure embedding some topics

I am embedding discourse on my website as a discussion plugin as described in

In the recent past for a number of topics I get a “Fehler bei der Einbettung” message (discourse/server.de.yml at 8adec48b335b8cdf3ee7d674e0075f7f461e3a97 · discourse/discourse · GitHub).

I am just trying to figure why that happens. No topic gets created. It used to help to reload the page and after a topic had been created usually things worked fine but now it seems to be stuck on the error.

In the jacascript console I see a message “SyntaxError: An invalid or illegal string was specified”. I traced that back to


where the call to postMessage(msg, referer) contains an empty referer.

I don’t really understand the problem (the message being sent contains an error message) but the error handling seems broken.

When I look in the discourse logs it seems that this error is connected:

Job exception: unexpected ‘$’ after ’ ’

backtrace

> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/nokogiri-1.10.4/lib/nokogiri/css/parser_extras.rb:87:in `on_error'
> /usr/local/lib/ruby/2.6.0/racc/parser.rb:259:in `_racc_do_parse_c'
> /usr/local/lib/ruby/2.6.0/racc/parser.rb:259:in `do_parse'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/nokogiri-1.10.4/lib/nokogiri/css/parser_extras.rb:62:in `parse'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/nokogiri-1.10.4/lib/nokogiri/css/parser_extras.rb:79:in `xpath_for'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/nokogiri-1.10.4/lib/nokogiri/css.rb:23:in `xpath_for'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/nokogiri-1.10.4/lib/nokogiri/xml/searchable.rb:207:in `block in xpath_query_from_css_rule'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/nokogiri-1.10.4/lib/nokogiri/xml/searchable.rb:206:in `map'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/nokogiri-1.10.4/lib/nokogiri/xml/searchable.rb:206:in `xpath_query_from_css_rule'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/nokogiri-1.10.4/lib/nokogiri/xml/searchable.rb:202:in `block in css_rules_to_xpath'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/nokogiri-1.10.4/lib/nokogiri/xml/searchable.rb:202:in `map'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/nokogiri-1.10.4/lib/nokogiri/xml/searchable.rb:202:in `css_rules_to_xpath'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/nokogiri-1.10.4/lib/nokogiri/xml/searchable.rb:171:in `css_internal'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/nokogiri-1.10.4/lib/nokogiri/xml/searchable.rb:107:in `css'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/ruby-readability-0.7.0/lib/readability.rb:79:in `handle_exclusions!'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/ruby-readability-0.7.0/lib/readability.rb:54:in `initialize'
> /var/www/discourse/app/models/topic_embed.rb:131:in `new'
> /var/www/discourse/app/models/topic_embed.rb:131:in `find_remote'
> /var/www/discourse/app/models/topic_embed.rb:177:in `import_remote'
> /var/www/discourse/lib/topic_retriever.rb:58:in `fetch_http'
> /var/www/discourse/lib/topic_retriever.rb:45:in `perform_retrieve'
> /var/www/discourse/lib/topic_retriever.rb:12:in `retrieve'
> /var/www/discourse/app/jobs/regular/retrieve_topic.rb:15:in `execute'
> /var/www/discourse/app/jobs/base.rb:232:in `block (2 levels) in perform'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rails_multisite-2.0.7/lib/rails_multisite/connection_management.rb:63:in `with_connection'
> /var/www/discourse/app/jobs/base.rb:221:in `block in perform'
> /var/www/discourse/app/jobs/base.rb:217:in `each'
> /var/www/discourse/app/jobs/base.rb:217:in `perform'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:192:in `execute_job'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:165:in `block (2 levels) in process'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/middleware/chain.rb:128:in `block in invoke'
> /var/www/discourse/lib/sidekiq/pausable.rb:138:in `call'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/middleware/chain.rb:133:in `invoke'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:164:in `block in process'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:137:in `block (6 levels) in dispatch'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/job_retry.rb:109:in `local'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:136:in `block (5 levels) in dispatch'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq.rb:37:in `block in <module:Sidekiq>'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:132:in `block (4 levels) in dispatch'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:250:in `stats'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:127:in `block (3 levels) in dispatch'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/job_logger.rb:8:in `call'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:126:in `block (2 levels) in dispatch'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/job_retry.rb:74:in `global'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:125:in `block in dispatch'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/logging.rb:48:in `with_context'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/logging.rb:42:in `with_job_hash_context'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:124:in `dispatch'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:163:in `process'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:83:in `process_one'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:71:in `run'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/util.rb:16:in `watchdog'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/util.rb:25:in `block in safe_thread'

as exclusion was mentioned in the backtrace I removed all exclusion (and inclusion) rules. That way all went back to the behavior I knew. Failure in the beginning. Success after reloading.

I’ll check the exclusion criteria and see which ones are most problematic.

Are you embedding Discourse on the same domain? You might want to look at the embed_any_origin setting.

2 Likes