Skip to content

Commit 262c0c8

Browse files
committed
Don't truncate exception backtrace when there's no limit specified
For PostgreSQL and SQLite, instead of having them conform to the same limit as MySQL, just let them store the whole backtrace. I tried using a LONGTEXT column for MySQL but the schema is incompatible with PostgreSQL and SQLite, and it was getting a bit too complicated.
1 parent fc84292 commit 262c0c8

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

app/models/solid_queue/failed_execution.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def retry
3434

3535
private
3636
JSON_OVERHEAD = 256
37-
DEFAULT_ERROR_SIZE_LIMIT = 64.kilobytes
3837

3938
def expand_error_details_from_exception
4039
if exception
@@ -51,19 +50,18 @@ def exception_message
5150
end
5251

5352
def exception_backtrace
54-
limit = determine_backtrace_size_limit
55-
56-
if exception.backtrace.to_json.bytesize <= limit
57-
exception.backtrace
58-
else
53+
if (limit = determine_backtrace_size_limit) && exception.backtrace.to_json.bytesize > limit
5954
truncate_backtrace(exception.backtrace, limit)
55+
else
56+
exception.backtrace
6057
end
6158
end
6259

6360
def determine_backtrace_size_limit
6461
column = self.class.connection.schema_cache.columns_hash(self.class.table_name)["error"]
65-
66-
(column&.limit || DEFAULT_ERROR_SIZE_LIMIT) - exception_class_name.bytesize - exception_message.bytesize - JSON_OVERHEAD
62+
if column.limit.present?
63+
column.limit - exception_class_name.bytesize - exception_message.bytesize - JSON_OVERHEAD
64+
end
6765
end
6866

6967
def truncate_backtrace(lines, limit)

0 commit comments

Comments
 (0)