que 0.14.2 → 0.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91851179dace9028e7617410ea3214b2f465aa20399db4714c91aa533682a326
4
- data.tar.gz: 42935a8c9b1d8c709b7e39c590d2d1b062474dc509c66c0e5e87650bf40b39ac
3
+ metadata.gz: 73f8f07b0a406399663e08cbfd7faddaf5239b5ac08d29320eb8651e76dd1671
4
+ data.tar.gz: 6fc8445aed22c679a323ac22941e9f9037f668840a97fc16b7915850d494f668
5
5
  SHA512:
6
- metadata.gz: 2635539c039b7e30736d8032bf8c27210624b98695f98c30053dff29345cc6368eb864315b32a41ea79a8af7a91f0c76c89924e73b652fe4edc08f15b1b65e41
7
- data.tar.gz: 28d797216ae91e9cc15aee815c51308432f45d87dbc9cfc966d500496eec4efecb018c99dcf19fc0edb46bdd925ca35967eb10da325dfde642dafceb5f38297b
6
+ metadata.gz: 6020097fb14b30ce4775a34124ef7e40d52d8f56381286bab98e2e670626fac61c137f685f6ba87443143d52eee4e366bed96177bcb4e196b72c84546c022e07
7
+ data.tar.gz: 916cbe011fc1d742b1559997ad71dbc9822bf68c56ce629d2cf7e01a2bd218dd6b626eb09ac873da0be1e3c770fcfe75a245361e418c01787fc10d7c85b4e1f2
@@ -4,7 +4,8 @@ cache: bundler
4
4
  rvm:
5
5
  - 2.2
6
6
  - 2.3
7
- - 2.4.0
7
+ - 2.4
8
+ - 2.5
8
9
  - ruby-head
9
10
  # The Rubinii aren't installing properly on Travis :/
10
11
  # - rbx-2
@@ -1,3 +1,9 @@
1
+ ### 0.14.3 (2018-03-02)
2
+
3
+ * Recorded errors now always include the error class, so that empty error messages can still be helpful. ( joehorsnell)
4
+
5
+ * Recorded error messages are now truncated to the first 500 characters.
6
+
1
7
  ### 0.14.2 (2018-01-05)
2
8
 
3
9
  * Deprecate the Que.disable_prepared_statements= accessors.
@@ -33,6 +33,10 @@ module Que
33
33
  @attrs[:error_count]
34
34
  end
35
35
 
36
+ def error_message
37
+ self.class.send(:error_message, @_error)
38
+ end
39
+
36
40
  def handle_error(error)
37
41
  error_count = @attrs[:error_count] += 1
38
42
  retry_interval = self.class.retry_interval || Job.retry_interval
@@ -41,7 +45,6 @@ module Que
41
45
  end
42
46
 
43
47
  def retry_in(period)
44
- error_message = "#{@_error.message}\n#{@_error.backtrace.join("\n")}"
45
48
  Que.execute :set_error, [period, error_message] + @attrs.values_at(:queue, :priority, :run_at, :job_id)
46
49
  @retried = true
47
50
  end
@@ -142,7 +145,7 @@ module Que
142
145
  count = job[:error_count].to_i + 1
143
146
  interval = klass && klass.respond_to?(:retry_interval) && klass.retry_interval || retry_interval
144
147
  delay = interval.respond_to?(:call) ? interval.call(count) : interval
145
- message = "#{error.message}\n#{error.backtrace.join("\n")}"
148
+ message = error_message(error)
146
149
  Que.execute :set_error, [delay, message] + job.values_at(:queue, :priority, :run_at, :job_id)
147
150
  end
148
151
  rescue
@@ -174,6 +177,18 @@ module Que
174
177
 
175
178
  private
176
179
 
180
+ def error_message(error)
181
+ message = error.class.to_s
182
+
183
+ unless error.message.nil? || error.message.strip.empty?
184
+ message << ": #{error.message}"
185
+ end
186
+
187
+ message = message.slice(0, 500)
188
+
189
+ ([message] + error.backtrace).join("\n")
190
+ end
191
+
177
192
  def class_for(string)
178
193
  Que.constantize(string)
179
194
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Que
4
- Version = '0.14.2'
4
+ Version = '0.14.3'
5
5
  end
@@ -237,7 +237,7 @@ describe Que::Job, '.work' do
237
237
  DB[:que_jobs].count.should be 1
238
238
  job = DB[:que_jobs].first
239
239
  job[:error_count].should be 1
240
- job[:last_error].should =~ /\AErrorJob!/
240
+ job[:last_error].should =~ /\ARuntimeError: ErrorJob!/
241
241
  job[:run_at].should be_within(3).of Time.now + 4
242
242
 
243
243
  DB[:que_jobs].update :error_count => 5,
@@ -251,7 +251,7 @@ describe Que::Job, '.work' do
251
251
  DB[:que_jobs].count.should be 1
252
252
  job = DB[:que_jobs].first
253
253
  job[:error_count].should be 6
254
- job[:last_error].should =~ /\AErrorJob!/
254
+ job[:last_error].should =~ /\ARuntimeError: ErrorJob!/
255
255
  job[:run_at].should be_within(3).of Time.now + 1299
256
256
  end
257
257
 
@@ -270,7 +270,7 @@ describe Que::Job, '.work' do
270
270
  DB[:que_jobs].count.should be 1
271
271
  job = DB[:que_jobs].first
272
272
  job[:error_count].should be 1
273
- job[:last_error].should =~ /\AErrorJob!/
273
+ job[:last_error].should =~ /\ARuntimeError: ErrorJob!/
274
274
  job[:run_at].to_f.should be_within(3).of Time.now.to_f + RetryIntervalJob.retry_interval
275
275
 
276
276
  DB[:que_jobs].update :error_count => 5,
@@ -284,7 +284,7 @@ describe Que::Job, '.work' do
284
284
  DB[:que_jobs].count.should be 1
285
285
  job = DB[:que_jobs].first
286
286
  job[:error_count].should be 6
287
- job[:last_error].should =~ /\AErrorJob!/
287
+ job[:last_error].should =~ /\ARuntimeError: ErrorJob!/
288
288
  job[:run_at].to_f.should be_within(3).of Time.now.to_f + RetryIntervalJob.retry_interval
289
289
  end
290
290
 
@@ -303,7 +303,7 @@ describe Que::Job, '.work' do
303
303
  DB[:que_jobs].count.should be 1
304
304
  job = DB[:que_jobs].first
305
305
  job[:error_count].should be 1
306
- job[:last_error].should =~ /\AErrorJob!/
306
+ job[:last_error].should =~ /\ARuntimeError: ErrorJob!/
307
307
  job[:run_at].should be_within(3).of Time.now + 10
308
308
 
309
309
  DB[:que_jobs].update :error_count => 5,
@@ -317,7 +317,7 @@ describe Que::Job, '.work' do
317
317
  DB[:que_jobs].count.should be 1
318
318
  job = DB[:que_jobs].first
319
319
  job[:error_count].should be 6
320
- job[:last_error].should =~ /\AErrorJob!/
320
+ job[:last_error].should =~ /\ARuntimeError: ErrorJob!/
321
321
  job[:run_at].should be_within(3).of Time.now + 60
322
322
  end
323
323
 
@@ -404,6 +404,46 @@ describe Que::Job, '.work' do
404
404
  job[:run_at].should be_within(3).of Time.now + 4
405
405
  end
406
406
 
407
+ it "should use the class name of the exception if its message is blank when setting last_error" do
408
+ class BlankExceptionMessageJob < Que::Job
409
+ def self.error
410
+ @error ||= RuntimeError.new("")
411
+ end
412
+
413
+ def run
414
+ raise self.class.error
415
+ end
416
+ end
417
+
418
+ BlankExceptionMessageJob.enqueue
419
+ result = Que::Job.work
420
+ result[:event].should == :job_errored
421
+ job = DB[:que_jobs].first
422
+ job[:error_count].should be 1
423
+ last_error_lines = job[:last_error].split("\n")
424
+ last_error_lines.should == %w[RuntimeError] + BlankExceptionMessageJob.error.backtrace
425
+ end
426
+
427
+ it "should use the class name of the exception if its message is blank when setting last_error" do
428
+ class LongExceptionMessageJob < Que::Job
429
+ def self.error
430
+ @error ||= RuntimeError.new("a" * 500)
431
+ end
432
+
433
+ def run
434
+ raise self.class.error
435
+ end
436
+ end
437
+
438
+ LongExceptionMessageJob.enqueue
439
+ result = Que::Job.work
440
+ result[:event].should == :job_errored
441
+ job = DB[:que_jobs].first
442
+ job[:error_count].should be 1
443
+ last_error_lines = job[:last_error].split("\n")
444
+ last_error_lines.should == ["RuntimeError: #{'a' * 486}"] + LongExceptionMessageJob.error.backtrace
445
+ end
446
+
407
447
  context "in a job class that has a custom error handler" do
408
448
  it "should allow it to schedule a retry after a specific interval" do
409
449
  begin
@@ -434,7 +474,7 @@ describe Que::Job, '.work' do
434
474
  job[:error_count].should be 1
435
475
 
436
476
  lines = job[:last_error].split("\n")
437
- lines[0].should == "Blah!"
477
+ lines[0].should == "RuntimeError: Blah!"
438
478
  lines[1].should =~ /work_spec/
439
479
  job[:run_at].should be_within(3).of Time.now + 42
440
480
 
@@ -543,7 +583,7 @@ describe Que::Job, '.work' do
543
583
  DB[:que_jobs].count.should be 1
544
584
  job = DB[:que_jobs].first
545
585
  job[:error_count].should be 1
546
- job[:last_error].should =~ /\ABlah!/
586
+ job[:last_error].should =~ /\ARuntimeError: Blah!/
547
587
  job[:run_at].should be_within(3).of Time.now + 4
548
588
 
549
589
  error.should == result[:error]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: que
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.2
4
+ version: 0.14.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Hanks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-05 00:00:00.000000000 Z
11
+ date: 2018-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler