Skip to content

Add tests for Deferred log context capture and backward-compatible restore#274

Merged
rsamoilov merged 1 commit intorage-rb:mainfrom
jsxs0:add-deferred-log-context-tests
Apr 16, 2026
Merged

Add tests for Deferred log context capture and backward-compatible restore#274
rsamoilov merged 1 commit intorage-rb:mainfrom
jsxs0:add-deferred-log-context-tests

Conversation

@jsxs0
Copy link
Copy Markdown
Contributor

@jsxs0 jsxs0 commented Apr 14, 2026

Summary

While working on the SSE context propagation tests in #267, I traced how log context flows across fiber boundaries in the Deferred system, specifically Context.build (capture) and restore_log_info in Task (restore). I noticed two paths without test coverage:

1. Context.build log context capture

The "when rage_logger is set" context verified context[4] (log tags) but not context[5] (log context). Added a test confirming Fiber[:__rage_logger_context] is captured, and fixed the after block to clean up both fiber-locals.

2. restore_log_info backward compatibility

restore_log_info has three branches: the current Array format, a legacy string format (older versions stored request_id as a plain string at index 4), and nil. The Array and nil branches were tested, but the legacy string path, which wraps the value into an array and defaults context to {}, had no coverage.

Test plan

bundle exec rspec spec/deferred/context_spec.rb spec/deferred/task_spec.rb
58 examples, 0 failures

@jsxs0 jsxs0 force-pushed the add-deferred-log-context-tests branch from 55c7c51 to 642c154 Compare April 14, 2026 06:21
Copy link
Copy Markdown
Member

@rsamoilov rsamoilov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing!

@rsamoilov rsamoilov merged commit 88930b2 into rage-rb:main Apr 16, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants