Unverified Commit a5f65903 authored by Hendrik Liebau's avatar Hendrik Liebau Committed by GitHub

Skip Server Function logging for `'use cache'` functions (#89408)

Follow-up to #89407.

Disables Server Function logging for `'use cache'` functions called from
the client.

The logging output for these Server Functions needs more work to be
useful. Currently it shows internal details like `$$RSC_SERVER_CACHE_0`
instead of the actual function name, as well as the encoded bound args
promise.
parent 93fc3597
...@@ -58,6 +58,7 @@ import { ...@@ -58,6 +58,7 @@ import {
} from './manifests-singleton' } from './manifests-singleton'
import { isNodeNextRequest, isWebNextRequest } from '../base-http/helpers' import { isNodeNextRequest, isWebNextRequest } from '../base-http/helpers'
import { normalizeFilePath } from './segment-explorer-path' import { normalizeFilePath } from './segment-explorer-path'
import { extractInfoFromServerReferenceId } from '../../shared/lib/server-reference-info'
import type { ServerActionLogInfo } from '../dev/server-action-logger' import type { ServerActionLogInfo } from '../dev/server-action-logger'
import { RedirectStatusCode } from '../../client/components/redirect-status-code' import { RedirectStatusCode } from '../../client/components/redirect-status-code'
import { synchronizeMutableCookies } from '../async-storage/request-store' import { synchronizeMutableCookies } from '../async-storage/request-store'
...@@ -1086,9 +1087,13 @@ export async function handleAction({ ...@@ -1086,9 +1087,13 @@ export async function handleAction({
// Log server action call in development when enabled // Log server action call in development when enabled
let logInfo: ServerActionLogInfo | null = null let logInfo: ServerActionLogInfo | null = null
const { type: actionType } = extractInfoFromServerReferenceId(actionId!)
if ( if (
process.env.NODE_ENV === 'development' && process.env.NODE_ENV === 'development' &&
ctx.renderOpts.logServerFunctions ctx.renderOpts.logServerFunctions &&
// TODO: For now, skip logging for 'use cache' Server Functions as the
// output needs more work, or a different approach entirely.
actionType !== 'use-cache'
) { ) {
const serverActionsManifest = getServerActionsManifest() const serverActionsManifest = getServerActionsManifest()
const runtime = process.env.NEXT_RUNTIME === 'edge' ? 'edge' : 'node' const runtime = process.env.NEXT_RUNTIME === 'edge' ? 'edge' : 'node'
......
...@@ -1419,6 +1419,22 @@ describe('use-cache', () => { ...@@ -1419,6 +1419,22 @@ describe('use-cache', () => {
const numbers = await browser.elementById('numbers').text() const numbers = await browser.elementById('numbers').text()
expect(numbers).toBe(initialNumbers) expect(numbers).toBe(initialNumbers)
}) })
if (isNextDev) {
it('should not log "use cache" functions called from client', async () => {
const browser = await next.browser('/passed-to-client')
const outputIndex = next.cliOutput.length
await browser.elementByCss('#submit-button').click()
await retry(() => {
const logs = stripAnsi(next.cliOutput.slice(outputIndex))
// Should have the POST request but not the function log
expect(logs).toContain('POST /passed-to-client')
expect(logs).not.toContain('└─ ƒ')
})
})
}
}) })
async function getSanitizedLogs(browser: Playwright): Promise<string[]> { async function getSanitizedLogs(browser: Playwright): Promise<string[]> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment