Always consider `captureOwnerStack` optional (#81370)
When running `next build` with a custom `NODE_ENV` (e.g. `test` or
`development`), the `captureOwnerStack` method is not defined and may
lead to errors if called. This change ensures that we only call
`captureOwnerStack` if it is defined, preventing potential runtime
errors.