Skip to content

Conversation

@dancastillo
Copy link
Member

Checklist

typescript tests are failing because pino v9.8.0 introduced msgPrefix in this PR pinojs/pino#2232

@github-actions github-actions bot added the typescript TypeScript related label Aug 11, 2025
Copy link
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

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

I don't know what this TypeScript stuff is trying to do, but we shouldn't have to pin the pino dependency and extra features of Pino shouldn't ever break anything here. Fastify is quite clear what it expects a logger to minimally look like. That doesn't mean any logger that meets that minimum requirement can't have its own feature set.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@gurgunday
Copy link
Member

I don't know what this TypeScript stuff is trying to do, but we shouldn't have to pin the pino dependency and extra features of Pino shouldn't ever break anything here. Fastify is quite clear what it expects a logger to minimally look like. That doesn't mean any logger that meets that minimum requirement can't have its own feature set.

well then it should also be fixed on pino's side right? AFAIU pino made a breaking type change?

Copy link
Member

@gurgunday gurgunday left a comment

Choose a reason for hiding this comment

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

lgtm for fixing the CI

@jsumners
Copy link
Member

I don't know what this TypeScript stuff is trying to do, but we shouldn't have to pin the pino dependency and extra features of Pino shouldn't ever break anything here. Fastify is quite clear what it expects a logger to minimally look like. That doesn't mean any logger that meets that minimum requirement can't have its own feature set.

well then it should also be fixed on pino's side right? AFAIU pino made a breaking type change?

A feature was added to Pino that allows the user to retrieve the configured "message prefix" for the current logger instance (root, child, etc). See pinojs/pino@4605454. This is not a breaking change. It is a new feature that has no bearing any of the logger methods (.info, etc) nor on the .child method. It is a completely transparent addition to anyone utilizing Pino according to the minimally required interface of Fastify:

/**
* Determines if a provided logger object meets the requirements
* of a Fastify compatible logger.
*
* @param {object} logger Object to validate.
* @param {boolean?} strict `true` if the object must be a logger (always throw if any methods missing)
*
* @returns {boolean} `true` when the logger meets the requirements.
*
* @throws {FST_ERR_LOG_INVALID_LOGGER} When the logger object is
* missing required methods.
*/
function validateLogger (logger, strict) {
const methods = ['info', 'error', 'debug', 'fatal', 'warn', 'trace', 'child']
const missingMethods = logger
? methods.filter(method => !logger[method] || typeof logger[method] !== 'function')
: methods
if (!missingMethods.length) {
return true
} else if ((missingMethods.length === methods.length) && !strict) {
return false
} else {
throw FST_ERR_LOG_INVALID_LOGGER(missingMethods.join(','))
}
}

@gurgunday
Copy link
Member

I see, thanks for the explanation

Well, I think the problem is here:

        /**
         * Get `msgPrefix` of the logger instance.
         *
         * See {@link https://github.com/pinojs/pino/blob/main/docs/api.md#msgprefix-string}.
         */
        get msgPrefix(): string | undefined;

It should be something like:

        /**
         * Get `msgPrefix` of the logger instance.
         *
         * See {@link https://github.com/pinojs/pino/blob/main/docs/api.md#msgprefix-string}.
         */
        readonly msgPrefix?: string;

But we lose the getter specification

The type change is breaking (in the sense that it breaks our tests)

@gurgunday
Copy link
Member

We can either do this PR or change the type definition, I'm fine with either

@dancastillo
Copy link
Member Author

Here is the PR to update the type definition #6287. I can close out this PR if that is the approach we want to take

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

Labels

typescript TypeScript related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants