Skip to content

Commit 3c6b53a

Browse files
authored
fix: support lazy startup log messages (#8054)
`flushStartupLogs` is called both with the main `./log` module (which natively supports deferred/lazy message formatting via function arguments) and with the simpler `./log/writer` pass-through (which does not). Callers that push a closure onto the warnings queue — as recommended by the log module's docs for expensive formatting — ended up being stringified to `[object Function]` when the writer was used. Invoke the closure at the call site so both log surfaces behave consistently. This is a minimal, self-contained fix with no change to the public API: callers that pass a string still work exactly as before.
1 parent 0b7ef41 commit 3c6b53a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packages/datadog-instrumentations/src/helpers/check-require-cache.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ module.exports.checkForPotentialConflicts = function () {
9797
}
9898

9999
module.exports.flushStartupLogs = function (log) {
100+
// Some callers pass `./log/writer` (simple pass-through) while others pass the main `./log`
101+
// module (which supports lazy delegate functions). Invoke closures here so both work.
100102
while (warnings.length) {
101-
log.warn(warnings.shift())
103+
const entry = warnings.shift()
104+
log.warn(typeof entry === 'function' ? entry() : entry)
102105
}
103106
}

0 commit comments

Comments
 (0)