Skip to content

Conversation

@dimkl
Copy link
Contributor

@dimkl dimkl commented Aug 1, 2024

Description

We are using the withLogger wrapper to handle the logger.commit on every time the wrapped function is executed.

In clerkMiddleware we are wrapping the whole function with the withLogger instead of the returned nextMiddleware that is executed in every request causing the logger.commit() to be executed once during the initialization of the clerkMiddleware() (on 1st request). To make debug logs working for clerkMiddleware on every request we need to move the withLogger to wrap the returned middleware instead.

In authMiddleware we are wrapping the returned nextMiddleware which makes the debugging logs works without any change.

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • [x ] 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

We are using the `withLogger` wrapper to handle the logger.commit on
every time the wrapped function is executed.

In `clerkMiddleware` we are wrapping the whole function with the
`withLogger` instead of the returned nextMiddleware that is executed
in every request causing the `logger.commit()` to be executed once
during the initialization of the `clerkMiddleware()` (on 1st request).
To make debug logs working for `clerkMiddleware` on every request we
need to move the `withLogger` to wrap the returned middleware instead.

In `authMiddleware` we are wrapping the returned nextMiddleware which
makes the debugging logs works without any change.
@dimkl dimkl requested a review from nikosdouvlis August 1, 2024 11:02
@dimkl dimkl self-assigned this Aug 1, 2024
@changeset-bot
Copy link

changeset-bot bot commented Aug 1, 2024

🦋 Changeset detected

Latest commit: 73a3cf2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clerk/nextjs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dimkl dimkl force-pushed the fix/nextjs-debug-logger branch from 63eab8e to 50e36a9 Compare August 1, 2024 11:03
@dimkl dimkl enabled auto-merge (squash) August 1, 2024 11:24
@nikosdouvlis nikosdouvlis disabled auto-merge August 1, 2024 11:44
@nikosdouvlis nikosdouvlis merged commit d4c8f2d into main Aug 1, 2024
@nikosdouvlis nikosdouvlis deleted the fix/nextjs-debug-logger branch August 1, 2024 11:44
wobsoriano pushed a commit that referenced this pull request Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants