mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
3265c95d0b
Similar to how #71669 fixed a race condition when setting the manifests singleton regarding the server action manifests, this PR fixes the same race condition for the client reference manifests.
41 lines
776 B
JavaScript
41 lines
776 B
JavaScript
import { Client } from './client'
|
|
import Form from './form'
|
|
|
|
async function otherAction() {
|
|
'use server'
|
|
return 'hi'
|
|
}
|
|
|
|
// Test top-level encryption (happens during the module load phase)
|
|
function wrapAction(value, action, element) {
|
|
return async function () {
|
|
'use server'
|
|
const v = await action()
|
|
if (v === 'hi') {
|
|
console.log(value)
|
|
}
|
|
return element
|
|
}
|
|
}
|
|
|
|
const action = wrapAction(
|
|
'some-module-level-encryption-value',
|
|
otherAction,
|
|
<Client />
|
|
)
|
|
|
|
// Test runtime encryption (happens during the rendering phase)
|
|
export default function Page() {
|
|
const secret = 'my password is qwerty123'
|
|
|
|
return (
|
|
<Form
|
|
action={async () => {
|
|
'use server'
|
|
console.log(secret)
|
|
return action()
|
|
}}
|
|
/>
|
|
)
|
|
}
|