Unverified Commit 9bd00a88 authored by Shu Ding's avatar Shu Ding Committed by GitHub

Add test case for client sourcemaps (#49308)

This PR adds a test case to ensure that the server reference doesn't expose actual content of the original file in its sourcemap.

Closes NEXT-1041.
parent 92ff2dd7
import { createNextDescribe } from 'e2e-utils' import { createNextDescribe } from 'e2e-utils'
import { check } from 'next-test-utils' import { check } from 'next-test-utils'
import { Request } from 'playwright-chromium' import { Request } from 'playwright-chromium'
import fs from 'fs-extra'
import { join } from 'path'
const GENERIC_RSC_ERROR = const GENERIC_RSC_ERROR =
'Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.' 'Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.'
...@@ -170,6 +172,24 @@ createNextDescribe( ...@@ -170,6 +172,24 @@ createNextDescribe(
await check(() => browser.elementByCss('h1').text(), '3') await check(() => browser.elementByCss('h1').text(), '3')
}) })
if (!isNextDev) {
it('should not expose action content in sourcemaps', async () => {
const sourcemap = (
await fs.readdir(
join(next.testDir, '.next', 'static', 'chunks', 'app', 'client')
)
).find((f) => f.endsWith('.js.map'))
expect(sourcemap).toBeDefined()
expect(
await next.readFile(
join('.next', 'static', 'chunks', 'app', 'client', sourcemap)
)
).not.toContain('this_is_sensitive_info')
})
}
if (isNextDev) { if (isNextDev) {
describe('HMR', () => { describe('HMR', () => {
it('should support updating the action', async () => { it('should support updating the action', async () => {
......
...@@ -11,6 +11,7 @@ export async function dec(value) { ...@@ -11,6 +11,7 @@ export async function dec(value) {
} }
export default async function (value) { export default async function (value) {
console.log('this_is_sensitive_info')
return value * 2 return value * 2
} }
......
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
module.exports = { module.exports = {
productionBrowserSourceMaps: true,
experimental: { experimental: {
serverActions: true, serverActions: true,
}, },
......
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