Skip to content

formatter: hang when formatting .vue <script> with deeply nested method chains and arrow callbacks #22350

@lozinsky

Description

@lozinsky

Description

oxfmt --check hangs (does not finish within 10 seconds, likely indefinitely or in exponential time) when formatting a Vue file whose <script lang="ts" setup> contains a deeply nested chain of yup.object({...}) with arrow callbacks passed to .when(() => ...).

The same content placed in a plain .ts file is formatted instantly, so the issue is specific to the embedded formatter path used for <script> blocks in .vue files.

This is a regression introduced in 0.41.0 - 0.40.0 formats the file in ~0.3s.

Reproduction

https://github.com/lozinsky/oxfmt-vue-nested-callbacks-deadlock

<script lang="ts" setup>
const schema = computed(() =>
  yup.object({
    a: yup.object({
      b: yup.object({
        c: yup.object().when(() =>
          yup.object({
            d: yup.object().when(() =>
              yup.object({
                e: yup.object({ f: yup.object({ g: yup.string() }) }),
              }),
            ),
          }),
        ),
      }),
    }),
  }),
);
</script>
npm i
npm run reproduce

Actual result

oxfmt@0.40.0: OK  (0.3s)
oxfmt@0.41.0: HANG (10.4s)
oxfmt@0.49.0: HANG (10.6s)

Reproduced on ubuntu-latest in GitHub Actions: https://github.com/lozinsky/oxfmt-vue-nested-callbacks-deadlock/actions/runs/25727888977/job/75545299487

Expected result

There should be no hangs.

Metadata

Metadata

Assignees

Labels

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions