Repository: next.js
Issue: Server actions are inconsistent `Error: Only plain objects, and a few built-ins, can be passed to Client Components from Server Components.` error is not always triggered.
Labels: bug

### Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/holy-water-wy8znd?file=%2Fapp%2Fpage.tsx%3A5%2C2&layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clxwgjln40006356nvlsda8zs%2522%252C%2522sizes%2522%253A%255B66.71746776084407%252C33.28253223915593%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clxwgjln40002356n8iohbmqd%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clxwgjln40004356n0bxbrrg6%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clxwgjln40005356n8j2t59fe%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clxwgjln40002356n8iohbmqd%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clxwgjln30001356nqzqjtat8%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252FREADME.md%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522id%2522%253A%2522clxwgk516001x356na4rgtqbb%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fnext.config.js%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522id%2522%253A%2522clxwglzeb0002356m90nkbzm9%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522initialSelections%2522%253A%255B%257B%2522startLineNumber%2522%253A5%252C%2522startColumn%2522%253A2%252C%2522endLineNumber%2522%253A5%252C%2522endColumn%2522%253A2%257D%255D%252C%2522filepath%2522%253A%2522%252Fapp%252Fpage.tsx%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%255D%252C%2522id%2522%253A%2522clxwgjln40002356n8iohbmqd%2522%252C%2522activeTabId%2522%253A%2522clxwglzeb0002356m90nkbzm9%2522%257D%252C%2522clxwgjln40005356n8j2t59fe%2522%253A%257B%2522id%2522%253A%2522clxwgjln40005356n8j2t59fe%2522%252C%2522activeTabId%2522%253A%2522clxwgpla000dy356m2eb0sxfq%2522%252C%2522tabs%2522%253A%255B%257B%2522type%2522%253A%2522UNASSIGNED_PORT%2522%252C%2522port%2522%253A3000%252C%2522id%2522%253A%2522clxwgpla000dy356m2eb0sxfq%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522path%2522%253A%2522%252F%2522%257D%255D%257D%252C%2522clxwgjln40004356n0bxbrrg6%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clxwgjln40003356n3cyi0tcs%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522dev%2522%257D%255D%252C%2522id%2522%253A%2522clxwgjln40004356n0bxbrrg6%2522%252C%2522activeTabId%2522%253A%2522clxwgjln40003356n3cyi0tcs%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D

### To Reproduce

1. Open link with the code
2. Notice how `foo = Lorem ipsum` on the client component

When creating a server action, i want to use fully statically typed features
```
`use server`
export async function myServerAction(request: TReq) : Promise<TRes> { ... }
```
```
`use client`
// boilerplate
const Component = () => {
  useEffect(() => {
    async submit() { 
      const req = new TReq(...);
      const result = await myServerAction(req);
      // do something
    }
  }, []);
}
```
but instead I get `Error: Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported.`

BUT instead i get randomly (installation based) different results.

### Current vs. Expected behavior

`foo = Lorem ipsum` should not be present based on exception provided below

When I run similar code like on codesandbox the result is identical, but I decided to run the same code from a different Windows User Account i get this error `Error: Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported.`

This issue is random, and installation is dependent. Everything is the same between those 2 Windows User Accounts. (npx --no-install next info results are the same), node-packaged are the same (run from the same folder)
 

### Provide environment information

```bash
Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro
  Available memory (MB): 49075
  Available CPU cores: 32
Binaries:
  Node: 19.8.1
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.2.4 // Latest available version is detected (14.2.4).
  eslint-config-next: 14.2.4
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.4.5
Next.js Config:
  output: N/A
```


### Which area(s) are affected? (Select all that apply)

Not sure

### Which stage(s) are affected? (Select all that apply)

next dev (local)

### Additional context

I understand that there might be limitations to this, but why next.js cannot do JSON.stringify() and JSON.parse() for me in the background? Or why cannot I write a custom serializer for the data somewhere and inject this serializer into the method? Instead I have to pass string -> string into server action methods?