now() inside a custom .dwl module always returns the same date/time value, regardless of when the request is made.This is expected DataWeave module behavior, not a product bug or runtime regression.
When a DataWeave module (.dwl file) is loaded, all module-level var declarations are evaluated on first access and their result permanently cached for the lifetime of the application. This means any dynamic expression — including now() — assigned to a module-level var is evaluated exactly once, at or shortly after application startup, and the same value is reused for every subsequent request.
// now() is evaluated ONCE at module load time
// and the same value is returned for all subsequent requests
var currentDate = now() as Date {format: "yyyy-MM-dd"}
This behavior is distinct from using now() inline in a transform body (after ---), which is re-evaluated on every request as expected:
%dw 2.0
output application/json
---
{
// now() is re-evaluated on every request
currentDate: now() as Date {format: "yyyy-MM-dd"}
}var to a fun. Unlike a var, a function body is re-executed on every invocation, ensuring now() returns a fresh, accurate timestamp with each request.Before:
var currentDate = now() as Date {format: "yyyy-MM-dd"}
var currentDateTime = now() as DateTime {format: "yyyy-MM-dd'T'HH:mm"}
After:
fun currentDate() = now() as Date {format: "yyyy-MM-dd"}
fun currentDateTime() = now() as DateTime {format: "yyyy-MM-dd'T'HH:mm"}
.dwl files to use function call syntax with ():// Before — referenced as a variable
%dw 2.0
import currentDate from modules::CustomUtil
---
// After — invoked as a function
import * from modules::CustomUtil
---
currentDate()
005390666

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.