Skip to content

Commit

Permalink
add compile timeout config
Browse files Browse the repository at this point in the history
  • Loading branch information
hooopo committed May 7, 2021
1 parent 498b594 commit 928d301
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def prepare

def self.create_new_context
# timeout any eval that takes longer than 15 seconds
ctx = MiniRacer::Context.new(timeout: 15000)
ctx = MiniRacer::Context.new(timeout: (ENV['COMPILE_TIMEOUT'] || 15000).to_i)
ctx.eval("var self = this; #{File.read("#{Rails.root}/vendor/assets/javascripts/babel.js")}")
ctx.eval(File.read(Ember::Source.bundled_path_for('ember-template-compiler.js')))
ctx.eval("module = {}; exports = {};")
Expand Down
2 changes: 1 addition & 1 deletion lib/js_locale_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def self.reset_context
def self.with_context
@mutex.synchronize do
yield @ctx ||= begin
ctx = MiniRacer::Context.new(timeout: 15000)
ctx = MiniRacer::Context.new(timeout: (ENV['COMPILE_TIMEOUT'] || 15000).to_i)
ctx.load("#{Rails.root}/lib/javascripts/messageformat.js")
ctx
end
Expand Down
2 changes: 1 addition & 1 deletion script/compile_hbs.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

ctx = MiniRacer::Context.new(timeout: 15000)
ctx = MiniRacer::Context.new(timeout: (ENV['COMPILE_TIMEOUT'] || 15000).to_i)
ctx.eval("var self = this; #{File.read("#{Rails.root}/vendor/assets/javascripts/babel.js")}")
ctx.eval(File.read(Ember::Source.bundled_path_for('ember-template-compiler.js')))
ctx.eval("module = {}; exports = {};")
Expand Down
2 changes: 1 addition & 1 deletion script/test_hbs_compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{{testing value="hello"}}
HBS

ctx = MiniRacer::Context.new(timeout: 15000)
ctx = MiniRacer::Context.new(timeout: (ENV['COMPILE_TIMEOUT'] || 15000).to_i)
ctx.eval("var self = this; #{File.read("#{Rails.root}/vendor/assets/javascripts/babel.js")}")
ctx.eval(File.read(Ember::Source.bundled_path_for('ember-template-compiler.js')))
ctx.eval("module = {}; exports = {};")
Expand Down

0 comments on commit 928d301

Please sign in to comment.