Skip to content

A platform for community discussion. Free, open, simple.

DEV: Don't serialize error objects back into js (#35468)

Jarek Radosze2e9b3b67944
diff --git a/lib/discourse_js_processor.rb b/lib/discourse_js_processor.rb
index dbf4ad45e5e..1a59b36cd24 100644
--- a/lib/discourse_js_processor.rb
+++ b/lib/discourse_js_processor.rb
@@ -43,9 +43,27 @@ class DiscourseJsProcessor
ctx = MiniRacer::Context.new(timeout: 15_000, ensure_gc_after_idle: 2000)
# General shims
- ctx.attach("rails.logger.info", proc { |err| Rails.logger.info(err.to_s) })
- ctx.attach("rails.logger.warn", proc { |err| Rails.logger.warn(err.to_s) })
- ctx.attach("rails.logger.error", proc { |err| Rails.logger.error(err.to_s) })
+ ctx.attach(
+ "rails.logger.info",
+ proc do |err|
+ Rails.logger.info(err.to_s)
+ nil
+ end,
+ )
+ ctx.attach(
+ "rails.logger.warn",
+ proc do |err|
+ Rails.logger.warn(err.to_s)
+ nil
+ end,
+ )
+ ctx.attach(
+ "rails.logger.error",
+ proc do |err|
+ Rails.logger.error(err.to_s)
+ nil
+ end,
+ )
source =
if Rails.env.production?
diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb
index 183cde9ca07..f765290dc50 100644
--- a/lib/pretty_text.rb
+++ b/lib/pretty_text.rb
@@ -46,9 +46,27 @@ module PrettyText
ctx.eval("window = globalThis; window.devicePixelRatio = 2;") # hack to make code think stuff is retina
- ctx.attach("rails.logger.info", proc { |err| Rails.logger.info(err.to_s) })
- ctx.attach("rails.logger.warn", proc { |err| Rails.logger.warn(err.to_s) })
- ctx.attach("rails.logger.error", proc { |err| Rails.logger.error(err.to_s) })
+ ctx.attach(
+ "rails.logger.info",
+ proc do |err|
+ Rails.logger.info(err.to_s)
+ nil
+ end,
+ )
+ ctx.attach(
+ "rails.logger.warn",
+ proc do |err|
+ Rails.logger.warn(err.to_s)
+ nil
+ end,
+ )
+ ctx.attach(
+ "rails.logger.error",
+ proc do |err|
+ Rails.logger.error(err.to_s)
+ nil
+ end,
+ )
ctx.eval <<~JS
console = {
prefix: "[PrettyText] ",