[🐞] Logging is not correct with fastify
Which component is affected?
Starters / CLI
Describe the bug
Run the following command.
npm run qwik add fastify
If some error occurs on the server side, the message "Cannot read properties of undefined (reading 'Symbol(pino.msgPrefix)')" will be left in the fastify log, which is not the original error message.
The following code is incorrect as the cause. https://github.com/BuilderIO/qwik/blob/176ba61d01d53271ff6fb63698324647c3f2fbf3/starters/adapters/fastify/src/plugins/fastify-qwik.ts#L33-L36
The correct code is as follows.
fastify.setNotFoundHandler(async (request, response) => {
const log = fastify.log
await router(request.raw, response.raw, log.error.bind(log));
await notFound(request.raw, response.raw, log.error.bind(log));
});
// OR
fastify.setNotFoundHandler(async (request, response) => {
await router(request.raw, response.raw, (err) => fastify.log.error(err));
await notFound(request.raw, response.raw, (err) => fastify.log.error(err));
});
Reproduction
https://stackblitz.com/edit/qwik-starter-gwz7c8?file=src/plugins/fastify-qwik.ts
Steps to reproduce
No response
System Info
System:
OS: Linux 5.15 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
CPU: (5) arm64 unknown
Memory: 8.02 GB / 11.68 GB
Container: Yes
Shell: 5.1.4 - /bin/bash
Binaries:
Node: 18.14.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 9.6.1 - /usr/local/share/npm-global/bin/npm
npmPackages:
@builder.io/qwik: 0.101.0 => 0.101.0
@builder.io/qwik-city: ~0.101.0 => 0.101.0
undici: 5.21.2 => 5.21.2
vite: 4.2.1 => 4.2.1
Additional Information
No response
Same issue here
Could you open a PR please? I would be happy to merge!