trigger.dev icon indicating copy to clipboard operation
trigger.dev copied to clipboard

bug: Logger unexpectedly formats date-like strings in payloads

Open isshaddad opened this issue 10 months ago • 7 comments

Provide environment information

Trigger v4.3.1

Describe the bug

The Trigger logger reformats date-like strings in payloads, even when they are explicitly formatted strings that should remain unchanged. When logging a payload containing a formatted date string like "Tuesday, January 6, 2026 10:05 AM", the logger converts it to an ISO-like format ("2026-01-06 10:04:00"), losing the original formatting.

Expected: the logger should preserve string values as-is, especially when they're already formatted date strings.

Reproduction repo

n/a

To reproduce

Create a payload object with a formatted date string:

const schedule = {
  "day": 1,
  "isValid": true,
  "sendTimeCST": "Tuesday, January 6, 2026 10:05 AM",
  "sendTimeUTC": "2026-01-06 16:05:11.132000000"
};

Log the payload using the Trigger logger:

logger.info("Schedule", { schedule });

Check the logged output, sendTimeCST will be reformatted.

Additional information

The issue can be bypassed by prefixing the string (e.g., "Date: Tuesday, January 6, 2026 10:05 AM")

isshaddad avatar Jan 14 '26 13:01 isshaddad

Hey i have tried to reproduce it locally, its working fine. Is there a specific scenario where you are facing this?

shivareddyvanja avatar Jan 14 '26 17:01 shivareddyvanja

Hi @ShivaReddyVanja,

I reported this through the bug report tool and can provide context - I was generating a test schedule locally for enqueuing future runs. The intent was to generate something like this to make sure that the send times were falling within business hours in local time:

[
  {
    day: 1,
    sendTimeUTC: 2026-01-14T19:21:11.468Z,
    sendTimeCST: 'Wednesday, January 14, 2026 01:21 PM',
    isValid: true
  },
  {
    day: 2,
    sendTimeUTC: 2026-01-16T14:00:00.000Z,
    sendTimeCST: 'Friday, January 16, 2026 08:00 AM',
    isValid: true
  },
  ....
]

SendtimeCST is a formatted version of the UTC time, using dayjs to format like this:

dayjs(date).tz('America/Chicago').format('dddd, MMMM D, YYYY hh:mm A')

When logging to the console, the correct formatted value is returned (e.g. "sendTimeCST": "Wednesday, January 14, 2026 01:21 PM"). When using logger, I get a reformatted value instead (e.g. "sendTimeCST": "2026-01-14 13:21:00").

typeof(sendTimeCST) is a string. Prefixing sendTimeCST with another string prevents the value from being reformatted, but just string interpolation does not:

// Returns "Date: Wednesday, January 14, 2026 01:45 PM"
`Date: ${GetFormattedCentralTime(sendTime)}`

// Returns "2026-01-14 13:21:00"
`${GetFormattedCentralTime(sendTime)}`

I also tried defining the array manually and got the same result. Have tried with trigger versions: 4.3.1 and 4.3.2.

Still seeing this on my end. Definitely possible i'm missing something - I'm just not sure what. Thanks!

dustb0wl avatar Jan 14 '26 19:01 dustb0wl

@dustb0wl Thanks for the context, i will use this info. and try to fix it asap.

shivareddyvanja avatar Jan 15 '26 03:01 shivareddyvanja

Hey i found the issue , but its only happening on trigger deployment, on my machine it is displaying properly. After lot of digging, i found that trigger backend is using @remix-typedjson which serializes the string into date object and sends it to the frontend Backend send the data like this, here the main culprit is typedjson:

const presenter = new LogDetailPresenter($replica, clickhouseClient);

  const result = await presenter.call({
    environmentId: environment.id,
    organizationId: project.organizationId,
    projectId: project.id,
    spanId,
    traceId,
    startTime,
  });

  if (!result) {
    throw new Response("Log not found", { status: 404 });
  }

  return typedjson(result);

So the original frontend code handle this like :

const logWithExtras = log as LogEntry & {
   attributes?: LogAttributes;
 };


 let beautifiedAttributes: string | null = null;

 if (logWithExtras.attributes) {
   beautifiedAttributes = JSON.stringify(logWithExtras.attributes, null, 2);
   beautifiedAttributes = formatStringJSON(beautifiedAttributes);
 }

I have created a frontend fix like this, which takes tries to display the string rawAttributes which is returned by the server response:(preserves the original string):

if (logWithExtras.rawAttributes) {
    try {
      // It's a string, so we need to parse it first to be able to re-stringify it with indentation
      const parsed = JSON.parse(logWithExtras.rawAttributes);
      beautifiedAttributes = JSON.stringify(parsed, null, 2);
    } catch (e) {
      beautifiedAttributes = logWithExtras.rawAttributes;
    }
    // We already have the raw string, so we don't need to format it again
    if (beautifiedAttributes) {
      beautifiedAttributes = formatStringJSON(beautifiedAttributes);
    }
  } else if (logWithExtras.attributes) {
    beautifiedAttributes = JSON.stringify(logWithExtras.attributes, null, 2);
    beautifiedAttributes = formatStringJSON(beautifiedAttributes);
  }

Im not able to prove this cause, my local environment displalyed correct format even before the fix, but this doesnt break anything. I will be linking the PR ,please check it.

shivareddyvanja avatar Jan 15 '26 08:01 shivareddyvanja

@dustb0wl where exactly are you seeing the "sendTimeCST": "2026-01-14 13:21:00"?

ericallam avatar Jan 15 '26 14:01 ericallam

@ericallam I tried the issue they were describing, I created a new task to log the payload they provided, on the trigger website(official). When the task ran , it logged given Custom string as stringified date object.

shivareddyvanja avatar Jan 15 '26 19:01 shivareddyvanja

@ericallam in the task run logs in the trigger.dev webapp -> (logger event in question)-> properties. Thanks!

dustb0wl avatar Jan 22 '26 19:01 dustb0wl