Skip to content

Commit f4d833d

Browse files
committed
fix onebox exception, if oneboxes fail on save we log a warning to the log
1 parent d43bd55 commit f4d833d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

app/models/post_analyzer.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@ def initialize(raw, topic_id)
99
def cook(*args)
1010
cooked = PrettyText.cook(*args)
1111

12-
# If we have any of the oneboxes in the cache, throw them in right away, don't
13-
# wait for the post processor.
12+
# cook all oneboxes, in the past we used to defer this
13+
# for some reason we decided to do this inline now
14+
# TODO: discuss on http://meta.discourse.org what the correct thing is to do
15+
# keep in mind some oneboxes may take a long time to build
1416
result = Oneboxer.apply(cooked) do |url, elem|
1517
Oneboxer.invalidate(url) if args.last[:invalidate_oneboxes]
16-
Oneboxer.onebox url
18+
begin
19+
Oneboxer.onebox url
20+
rescue => e
21+
Rails.logger.warn("Failed to cook onebox: #{e.message} #{e.backtrace}")
22+
nil
23+
end
1724
end
1825

1926
cooked = result.to_html if result.changed?

0 commit comments

Comments
 (0)