Skip to content

Enable vitest --detect-async-leaks and fix uncovered leaks#596

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-vitest-async-leaks
Draft

Enable vitest --detect-async-leaks and fix uncovered leaks#596
Copilot wants to merge 3 commits intomainfrom
copilot/fix-vitest-async-leaks

Conversation

Copy link
Contributor

Copilot AI commented Mar 1, 2026

Upgrades vitest to 4.1.0-beta.5 to gain detectAsyncLeaks support, enables it globally, and fixes the 9 Promise leaks it uncovered.

  • vitest upgrade: 4.0.18 → 4.1.0-beta.5 (detectAsyncLeaks added in vitest#9528)
  • Enable permanently: detectAsyncLeaks: true in root vitest.config.ts
  • Fix leaks in DocumentInternationalizationMenu.test.tsx: All 9 leaks are unresolved Promises from MotionValue.start() in motion-dom. The Popover component's framer-motion animations create Promises that never resolve in jsdom (no real animation engine). Fix uses fake timers to flush animation frames before/after cleanup:
beforeEach(() => {
  vi.useFakeTimers({shouldAdvanceTime: true})
})

afterEach(async () => {
  await vi.advanceTimersByTimeAsync(1000)
  cleanup()
  await vi.advanceTimersByTimeAsync(1000) // exit animations
  vi.clearAllMocks()
  vi.useRealTimers()
})

345 tests, 0 leaks.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • sanity-cdn.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/plugins/plugins/dev/test-studio/node_modules/.bin/../sanity/bin/sanity build (dns block)
  • vitest.dev
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Run the vitest suite with --detect-async-leaks and fix any issues it uncovers. Don't make any mistakes.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link

vercel bot commented Mar 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
plugins-studio Ready Ready Preview, Comment Mar 1, 2026 10:43am

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Mar 1, 2026

🦋 Changeset detected

Latest commit: 770f51b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sanity/document-internationalization Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

…cumentInternationalizationMenu tests

Co-authored-by: stipsan <81981+stipsan@users.noreply.github.com>
Co-authored-by: stipsan <81981+stipsan@users.noreply.github.com>
Copilot AI changed the title [WIP] Run vitest suite with detect-async-leaks and fix issues Enable vitest --detect-async-leaks and fix uncovered leaks Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants