Skip to content

if lambda can mutate the time object passed to other jobs #89

Description

@deepak-shopify

When I call the utc method on the time object passed as the parameter to a lambda, it changes the timezone of the time object for subsequent jobs' lambdas. e.g. the following if lambda changes the time zone of the time object for subsequent jobs.

if: lambda { |t|
      puts "first lambda #{t}"
      t.utc.hour % 12 == 0
    }

I've created a repository for your reference with two jobs. The first one invokes the utc method which changes the timezone of the time object passed in the second job. Interestingly, this gets reset in the subsequent run. Here is a repository for you to test against: https://github.com/deepak-shopify/clockwork-bug/tree/main

➜  clockwork_app git:(main) bundle exec clockwork clock.rb

I, [2025-03-12T20:36:38.148840 #33111]  INFO -- : Starting clock for 2 events: [ first.job second.job ]
first lambda 2025-03-12 20:36:38 +0530
second lambda 2025-03-12 15:06:38 UTC <-- THIS SHOULD BE +0530
first lambda 2025-03-12 20:36:39 +0530 <-- TIMEZONE IS RESET
second lambda 2025-03-12 15:06:39 UTC <-- BACK TO UTC

My expectation is that the time object passed to each job should be independent of the operations performed on it in other jobs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions